registerBackgroundMessageHandler method

Future<void> registerBackgroundMessageHandler(
  1. MessageHandler handler
)

This function registers background message handler to native side

Implementation

Future<void> registerBackgroundMessageHandler(MessageHandler handler) async {
  if (Platform.isIOS) {
    return;
  }

  if (!_bgHandlerInitialized) {
    _bgHandlerInitialized = true;
    HashMap<String, dynamic> list = HashMap();
    list[BACKGROUND_HANDLER] = PluginUtilities.getCallbackHandle(callbackDispatcher)!.toRawHandle();
    list[ON_PUSH_RECEIVE_BACKGROUND] = PluginUtilities.getCallbackHandle(handler)!.toRawHandle();
    await _channel.invokeMethod(START_BACKGROUND_ISOLATE, list);
  }
}