registerBackgroundMessageHandler static method

Future<bool> registerBackgroundMessageHandler(
  1. void callback(
    1. RemoteMessage remoteMessage
    )
)

Defines a function to handle background messages.

Implementation

static Future<bool> registerBackgroundMessageHandler(
  void Function(RemoteMessage remoteMessage) callback,
) async {
  final int rawHandle =
      PluginUtilities.getCallbackHandle(callbackDispatcher)!.toRawHandle();
  debugPrint('rawHandle $rawHandle');

  final int rawCallback =
      PluginUtilities.getCallbackHandle(callback)!.toRawHandle();
  debugPrint('rawCallback $rawCallback');

  final bool? result = await _methodChannel.invokeMethod(
    'registerBackgroundMessageHandler',
    <String, int>{
      'rawHandle': rawHandle,
      'rawCallback': rawCallback,
    },
  );
  return result!;
}