callbackDispatcher function

void callbackDispatcher()

Callback function for handling received RemoteMessage objects in the background.

Implementation

@pragma('vm:entry-point')
void callbackDispatcher() {
  WidgetsFlutterBinding.ensureInitialized();

  _backgroundMessageMethodChannel.setMethodCallHandler((MethodCall call) async {
    final RemoteMessage remoteMessage = RemoteMessage._fromMap(
      Map<String, dynamic>.from(call.arguments[1]),
    );
    final Function rawHandler = PluginUtilities.getCallbackFromHandle(
      CallbackHandle.fromRawHandle(call.arguments[0]),
    )!;
    rawHandler(remoteMessage);
  });
  _backgroundMessageMethodChannel.invokeMethod(
    'BackgroundRunner.initialize',
  );
}