From e4d7d12c4ace4d38e261ed7563c18f10778b55ad Mon Sep 17 00:00:00 2001 From: Ben Butterworth <24711048+ben-xD@users.noreply.github.com> Date: Thu, 18 Nov 2021 23:04:21 +0000 Subject: [PATCH 1/2] Rename `pushSetOnBackgroundMessage` to `pushBackgroundFlutterApplicationReadyOnAndroid` --- .../ably/flutter/plugin/BackgroundMethodCallHandler.java | 8 ++++---- .../ably/flutter/plugin/generated/PlatformConstants.java | 2 +- .../plugin/push/ManualFlutterApplicationRunner.java | 4 ++-- bin/codegen_context.dart | 5 ++++- ios/Classes/codec/AblyPlatformConstants.h | 2 +- ios/Classes/codec/AblyPlatformConstants.m | 2 +- lib/src/generated/platform_constants.dart | 9 ++++----- .../platform/src/push_notification_events_native.dart | 2 +- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/android/src/main/java/io/ably/flutter/plugin/BackgroundMethodCallHandler.java b/android/src/main/java/io/ably/flutter/plugin/BackgroundMethodCallHandler.java index 92848a0c5..d364de09a 100644 --- a/android/src/main/java/io/ably/flutter/plugin/BackgroundMethodCallHandler.java +++ b/android/src/main/java/io/ably/flutter/plugin/BackgroundMethodCallHandler.java @@ -1,6 +1,6 @@ package io.ably.flutter.plugin; -import static io.ably.flutter.plugin.generated.PlatformConstants.PlatformMethod.pushSetOnBackgroundMessage; +import static io.ably.flutter.plugin.generated.PlatformConstants.PlatformMethod.pushBackgroundFlutterApplicationReadyOnAndroid; import android.util.Log; @@ -15,7 +15,7 @@ * Receives method calls on the background method channel from the Dart side's * BackgroundIsolateAndroidPlatform to avoid exceptions being thrown in the case * where an Isolate doesn't need to be manually launched (App is already running), - * so `pushSetOnBackgroundMessage` platform method call doesn't need to be called. + * so `pushBackgroundFlutterApplicationReadyOnAndroid` platform method call doesn't need to be called. */ public class BackgroundMethodCallHandler implements MethodChannel.MethodCallHandler { private static final String TAG = AblyFlutterPlugin.class.getName(); @@ -27,8 +27,8 @@ public BackgroundMethodCallHandler(BinaryMessenger messenger, MethodCodec codec) @Override public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { - if (call.method.equals(pushSetOnBackgroundMessage)) { - Log.v(TAG, "Ignoring pushSetOnBackgroundMessage because it doesn't need to be called, " + + if (call.method.equals(pushBackgroundFlutterApplicationReadyOnAndroid)) { + Log.v(TAG, "Ignoring pushBackgroundFlutterApplicationReadyOnAndroid because it doesn't need to be called, " + "since the user's Flutter app (default DartEntrypoint) is already running."); } else { result.notImplemented(); diff --git a/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java b/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java index c31d14379..e7d85e75c 100644 --- a/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java +++ b/android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java @@ -84,7 +84,7 @@ static final public class PlatformMethod { public static final String pushOnMessage = "pushOnMessage"; public static final String pushOnBackgroundMessage = "pushOnBackgroundMessage"; public static final String pushOnNotificationTap = "pushOnNotificationTap"; - public static final String pushSetOnBackgroundMessage = "pushSetOnBackgroundMessage"; + public static final String pushBackgroundFlutterApplicationReadyOnAndroid = "pushBackgroundFlutterApplicationReadyOnAndroid"; public static final String onRealtimeConnectionStateChanged = "onRealtimeConnectionStateChanged"; public static final String onRealtimeChannelStateChanged = "onRealtimeChannelStateChanged"; public static final String onRealtimeChannelMessage = "onRealtimeChannelMessage"; diff --git a/android/src/main/java/io/ably/flutter/plugin/push/ManualFlutterApplicationRunner.java b/android/src/main/java/io/ably/flutter/plugin/push/ManualFlutterApplicationRunner.java index 335dc2ef9..93d974a72 100644 --- a/android/src/main/java/io/ably/flutter/plugin/push/ManualFlutterApplicationRunner.java +++ b/android/src/main/java/io/ably/flutter/plugin/push/ManualFlutterApplicationRunner.java @@ -1,7 +1,7 @@ package io.ably.flutter.plugin.push; import static io.ably.flutter.plugin.generated.PlatformConstants.PlatformMethod.pushOnBackgroundMessage; -import static io.ably.flutter.plugin.generated.PlatformConstants.PlatformMethod.pushSetOnBackgroundMessage; +import static io.ably.flutter.plugin.generated.PlatformConstants.PlatformMethod.pushBackgroundFlutterApplicationReadyOnAndroid; import android.content.Context; import android.content.Intent; @@ -63,7 +63,7 @@ public ManualFlutterApplicationRunner(@NonNull final Context context, @Override public void onMethodCall(@NonNull final MethodCall call, @NonNull final MethodChannel.Result result) { - if (call.method.equals(pushSetOnBackgroundMessage)) { + if (call.method.equals(pushBackgroundFlutterApplicationReadyOnAndroid)) { // This signals that the manually spawned app is ready to receive a message to handle. // We ask the user to set the background message handler early on. backgroundMethodChannel.invokeMethod(pushOnBackgroundMessage, remoteMessage, new MethodChannel.Result() { diff --git a/bin/codegen_context.dart b/bin/codegen_context.dart index 75adaa382..32d925cbc 100644 --- a/bin/codegen_context.dart +++ b/bin/codegen_context.dart @@ -129,7 +129,10 @@ const List> _platformMethods = [ {'name': 'pushOnBackgroundMessage', 'value': 'pushOnBackgroundMessage'}, {'name': 'pushOnNotificationTap', 'value': 'pushOnNotificationTap'}, // Used only on Android - {'name': 'pushSetOnBackgroundMessage', 'value': 'pushSetOnBackgroundMessage'}, + { + 'name': 'pushBackgroundFlutterApplicationReadyOnAndroid', + 'value': 'pushBackgroundFlutterApplicationReadyOnAndroid' + }, // Realtime events { diff --git a/ios/Classes/codec/AblyPlatformConstants.h b/ios/Classes/codec/AblyPlatformConstants.h index cb9ff4f40..fd5898e59 100644 --- a/ios/Classes/codec/AblyPlatformConstants.h +++ b/ios/Classes/codec/AblyPlatformConstants.h @@ -82,7 +82,7 @@ extern NSString *const AblyPlatformMethod_pushOnShowNotificationInForeground; extern NSString *const AblyPlatformMethod_pushOnMessage; extern NSString *const AblyPlatformMethod_pushOnBackgroundMessage; extern NSString *const AblyPlatformMethod_pushOnNotificationTap; -extern NSString *const AblyPlatformMethod_pushSetOnBackgroundMessage; +extern NSString *const AblyPlatformMethod_pushBackgroundFlutterApplicationReadyOnAndroid; extern NSString *const AblyPlatformMethod_onRealtimeConnectionStateChanged; extern NSString *const AblyPlatformMethod_onRealtimeChannelStateChanged; extern NSString *const AblyPlatformMethod_onRealtimeChannelMessage; diff --git a/ios/Classes/codec/AblyPlatformConstants.m b/ios/Classes/codec/AblyPlatformConstants.m index 6393e0100..dbf20374e 100644 --- a/ios/Classes/codec/AblyPlatformConstants.m +++ b/ios/Classes/codec/AblyPlatformConstants.m @@ -53,7 +53,7 @@ NSString *const AblyPlatformMethod_pushOnMessage= @"pushOnMessage"; NSString *const AblyPlatformMethod_pushOnBackgroundMessage= @"pushOnBackgroundMessage"; NSString *const AblyPlatformMethod_pushOnNotificationTap= @"pushOnNotificationTap"; -NSString *const AblyPlatformMethod_pushSetOnBackgroundMessage= @"pushSetOnBackgroundMessage"; +NSString *const AblyPlatformMethod_pushBackgroundFlutterApplicationReadyOnAndroid= @"pushBackgroundFlutterApplicationReadyOnAndroid"; NSString *const AblyPlatformMethod_onRealtimeConnectionStateChanged= @"onRealtimeConnectionStateChanged"; NSString *const AblyPlatformMethod_onRealtimeChannelStateChanged= @"onRealtimeChannelStateChanged"; NSString *const AblyPlatformMethod_onRealtimeChannelMessage= @"onRealtimeChannelMessage"; diff --git a/lib/src/generated/platform_constants.dart b/lib/src/generated/platform_constants.dart index e6a6b196c..37c8b4238 100644 --- a/lib/src/generated/platform_constants.dart +++ b/lib/src/generated/platform_constants.dart @@ -85,7 +85,8 @@ class PlatformMethod { static const String pushOnMessage = 'pushOnMessage'; static const String pushOnBackgroundMessage = 'pushOnBackgroundMessage'; static const String pushOnNotificationTap = 'pushOnNotificationTap'; - static const String pushSetOnBackgroundMessage = 'pushSetOnBackgroundMessage'; + static const String pushBackgroundFlutterApplicationReadyOnAndroid = + 'pushBackgroundFlutterApplicationReadyOnAndroid'; static const String onRealtimeConnectionStateChanged = 'onRealtimeConnectionStateChanged'; static const String onRealtimeChannelStateChanged = @@ -370,8 +371,7 @@ class TxPushRequestPermission { static const String alert = 'alert'; static const String carPlay = 'carPlay'; static const String criticalAlert = 'criticalAlert'; - static const String providesAppNotificationSettings = - 'providesAppNotificationSettings'; + static const String providesAppNotificationSettings = 'providesAppNotificationSettings'; static const String provisional = 'provisional'; static const String announcement = 'announcement'; } @@ -387,8 +387,7 @@ class TxUNNotificationSettings { static const String alertStyle = 'alertStyle'; static const String showPreviewsSetting = 'showPreviewsSetting'; static const String criticalAlertSetting = 'criticalAlertSetting'; - static const String providesAppNotificationSettings = - 'providesAppNotificationSettings'; + static const String providesAppNotificationSettings = 'providesAppNotificationSettings'; static const String announcementSetting = 'announcementSetting'; static const String scheduledDeliverySetting = 'scheduledDeliverySetting'; static const String timeSensitiveSetting = 'timeSensitiveSetting'; diff --git a/lib/src/platform/src/push_notification_events_native.dart b/lib/src/platform/src/push_notification_events_native.dart index 487295574..ff1ed07ad 100644 --- a/lib/src/platform/src/push_notification_events_native.dart +++ b/lib/src/platform/src/push_notification_events_native.dart @@ -57,7 +57,7 @@ class PushNotificationEventsNative implements PushNotificationEvents { _onBackgroundMessage = handler; if (io.Platform.isAndroid) { await BackgroundIsolateAndroidPlatform.methodChannel - .invokeMethod(PlatformMethod.pushSetOnBackgroundMessage); + .invokeMethod(PlatformMethod.pushBackgroundFlutterApplicationReadyOnAndroid); } } From 72d59c2dcc50fd5f97e37ec9291d81d263cc5ba7 Mon Sep 17 00:00:00 2001 From: Ben Butterworth <24711048+ben-xD@users.noreply.github.com> Date: Thu, 18 Nov 2021 23:09:29 +0000 Subject: [PATCH 2/2] Run `flutter format .` --- lib/src/generated/platform_constants.dart | 6 ++++-- lib/src/platform/src/push_notification_events_native.dart | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/generated/platform_constants.dart b/lib/src/generated/platform_constants.dart index 37c8b4238..1fbc8deac 100644 --- a/lib/src/generated/platform_constants.dart +++ b/lib/src/generated/platform_constants.dart @@ -371,7 +371,8 @@ class TxPushRequestPermission { static const String alert = 'alert'; static const String carPlay = 'carPlay'; static const String criticalAlert = 'criticalAlert'; - static const String providesAppNotificationSettings = 'providesAppNotificationSettings'; + static const String providesAppNotificationSettings = + 'providesAppNotificationSettings'; static const String provisional = 'provisional'; static const String announcement = 'announcement'; } @@ -387,7 +388,8 @@ class TxUNNotificationSettings { static const String alertStyle = 'alertStyle'; static const String showPreviewsSetting = 'showPreviewsSetting'; static const String criticalAlertSetting = 'criticalAlertSetting'; - static const String providesAppNotificationSettings = 'providesAppNotificationSettings'; + static const String providesAppNotificationSettings = + 'providesAppNotificationSettings'; static const String announcementSetting = 'announcementSetting'; static const String scheduledDeliverySetting = 'scheduledDeliverySetting'; static const String timeSensitiveSetting = 'timeSensitiveSetting'; diff --git a/lib/src/platform/src/push_notification_events_native.dart b/lib/src/platform/src/push_notification_events_native.dart index ff1ed07ad..d59ebf067 100644 --- a/lib/src/platform/src/push_notification_events_native.dart +++ b/lib/src/platform/src/push_notification_events_native.dart @@ -56,8 +56,8 @@ class PushNotificationEventsNative implements PushNotificationEvents { Future setOnBackgroundMessage(BackgroundMessageHandler handler) async { _onBackgroundMessage = handler; if (io.Platform.isAndroid) { - await BackgroundIsolateAndroidPlatform.methodChannel - .invokeMethod(PlatformMethod.pushBackgroundFlutterApplicationReadyOnAndroid); + await BackgroundIsolateAndroidPlatform.methodChannel.invokeMethod( + PlatformMethod.pushBackgroundFlutterApplicationReadyOnAndroid); } }