setBackgroundPushReceivedHandler method

Future<void> setBackgroundPushReceivedHandler(
  1. AndroidBackgroundPushReceivedHandler handler
)

Sets a background message handler.

Implementation

Future<void> setBackgroundPushReceivedHandler(
    AndroidBackgroundPushReceivedHandler handler) async {
  if (defaultTargetPlatform != TargetPlatform.android) {
    return;
  }
  if (_isBackgroundHandlerSet) {
    print("Airship background message handler already set!");
    return;
  }
  _isBackgroundHandlerSet = true;

  final isolateCallback = PluginUtilities.getCallbackHandle(
      _androidBackgroundMessageIsolateCallback)!;
  final messageCallback = PluginUtilities.getCallbackHandle(handler)!;
  await _module.channel.invokeMapMethod("startBackgroundIsolate", {
    "isolateCallback": isolateCallback.toRawHandle(),
    "messageCallback": messageCallback.toRawHandle()
  });
}