diff --git a/lib/src/platform/src/background_android_isolate_platform.dart b/lib/src/platform/src/background_android_isolate_platform.dart index 66ed831cb..cf743b3b5 100644 --- a/lib/src/platform/src/background_android_isolate_platform.dart +++ b/lib/src/platform/src/background_android_isolate_platform.dart @@ -22,12 +22,14 @@ class BackgroundIsolateAndroidPlatform { case PlatformMethod.pushOnBackgroundMessage: return _onPushBackgroundMessage(call.arguments as RemoteMessage); default: - throw PlatformException(code: 'invalid_method', message: 'No such method ${call.method}'); + throw PlatformException( + code: 'invalid_method', message: 'No such method ${call.method}'); } }); } - static final BackgroundIsolateAndroidPlatform _platform = BackgroundIsolateAndroidPlatform._internal(); + static final BackgroundIsolateAndroidPlatform _platform = + BackgroundIsolateAndroidPlatform._internal(); /// @nodoc /// Singleton instance of BackgroundIsolateAndroidPlatform @@ -37,15 +39,19 @@ class BackgroundIsolateAndroidPlatform { /// A method channel used to communicate with the user's app isolate /// we explicitly launched when a RemoteMessage is received. /// Used only on Android. - final MethodChannel _methodChannel = MethodChannel('io.ably.flutter.plugin.background', StandardMethodCodec(Codec())); + final MethodChannel _methodChannel = MethodChannel( + 'io.ably.flutter.plugin.background', StandardMethodCodec(Codec())); - final PushNotificationEventsInternal _pushNotificationEvents = Push.notificationEvents as PushNotificationEventsInternal; + final PushNotificationEventsInternal _pushNotificationEvents = + Push.notificationEvents as PushNotificationEventsInternal; - Future _onPushBackgroundMessage(RemoteMessage remoteMessage) async => _pushNotificationEvents.handleBackgroundMessage(remoteMessage); + Future _onPushBackgroundMessage(RemoteMessage remoteMessage) async => + _pushNotificationEvents.handleBackgroundMessage(remoteMessage); /// @nodoc /// Equivalent of [Platform.invokePlatformMethod] which cannot be used here /// because we may not be able to acquire [Platform] instance here, so we /// need to use a raw [MethodChannel] communication - Future invokeMethod(String method, [dynamic arguments]) async => _methodChannel.invokeMethod(method, arguments); + Future invokeMethod(String method, [dynamic arguments]) async => + _methodChannel.invokeMethod(method, arguments); } diff --git a/lib/src/platform/src/method_call_handler.dart b/lib/src/platform/src/method_call_handler.dart index 566ee9f0f..ac05625d8 100644 --- a/lib/src/platform/src/method_call_handler.dart +++ b/lib/src/platform/src/method_call_handler.dart @@ -94,7 +94,7 @@ class AblyMethodCallHandler { } Future _onPushBackgroundMessage(RemoteMessage remoteMessage) async { - _pushNotificationEvents.handleBackgroundMessage(remoteMessage); + await _pushNotificationEvents.handleBackgroundMessage(remoteMessage); return null; } diff --git a/lib/src/platform/src/push_notification_events_internal.dart b/lib/src/platform/src/push_notification_events_internal.dart index c5ec7b187..a00e42193 100644 --- a/lib/src/platform/src/push_notification_events_internal.dart +++ b/lib/src/platform/src/push_notification_events_internal.dart @@ -83,10 +83,11 @@ class PushNotificationEventsInternal implements PushNotificationEvents { /// Handles a RemoteMessage passed from the platform side. Future handleBackgroundMessage(RemoteMessage remoteMessage) async { if (_onBackgroundMessage != null) { - dynamic onBackgroundMessageResult = _onBackgroundMessage!(remoteMessage); + final onBackgroundMessageResult = _onBackgroundMessage!(remoteMessage); // ^^^ _onBackgroundMessage() can return void or Future - if (onBackgroundMessageResult is Future) { - await onBackgroundMessageResult; // if it returns a Future we await on it. + if (onBackgroundMessageResult is Future) { + // if it returns a Future we await on it. + await onBackgroundMessageResult; } } else { // ignore:avoid_print