Skip to content

Commit

Permalink
Inside of setupCallHandler() changed it to return from await.
Browse files Browse the repository at this point in the history
  • Loading branch information
asoap committed Dec 6, 2023
1 parent f8f92dd commit 8f67802
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/src/platform/src/background_android_isolate_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ class BackgroundIsolateAndroidPlatform {
_methodChannel.setMethodCallHandler((call) async {
switch (call.method) {
case PlatformMethod.pushOnBackgroundMessage:
await _onPushBackgroundMessage(call.arguments as RemoteMessage);
return;
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
Expand All @@ -40,19 +37,15 @@ 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<void> _onPushBackgroundMessage(RemoteMessage remoteMessage) async =>
_pushNotificationEvents.handleBackgroundMessage(remoteMessage);
Future<void> _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<T?> invokeMethod<T>(String method, [dynamic arguments]) async =>
_methodChannel.invokeMethod<T>(method, arguments);
Future<T?> invokeMethod<T>(String method, [dynamic arguments]) async => _methodChannel.invokeMethod<T>(method, arguments);
}

0 comments on commit 8f67802

Please sign in to comment.