Skip to content

Commit

Permalink
Merge pull request #236 from ably/enhancement/rename-pushSetOnBackgro…
Browse files Browse the repository at this point in the history
…undMessage-to-pushBackgroundFlutterApplicationReadyOnAndroid

Rename `pushSetOnBackgroundMessage` to `pushBackgroundFlutterApplicationReadyOnAndroid`
  • Loading branch information
QuintinWillison authored Nov 26, 2021
2 parents 858be21 + 95b6082 commit 006bb82
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion bin/codegen_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ const List<Map<String, dynamic>> _platformMethods = [
{'name': 'pushOnBackgroundMessage', 'value': 'pushOnBackgroundMessage'},
{'name': 'pushOnNotificationTap', 'value': 'pushOnNotificationTap'},
// Used only on Android
{'name': 'pushSetOnBackgroundMessage', 'value': 'pushSetOnBackgroundMessage'},
{
'name': 'pushBackgroundFlutterApplicationReadyOnAndroid',
'value': 'pushBackgroundFlutterApplicationReadyOnAndroid'
},

// Realtime events
{
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/codec/AblyPlatformConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/codec/AblyPlatformConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion lib/src/generated/platform_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions lib/src/platform/src/push_notification_events_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class PushNotificationEventsNative implements PushNotificationEvents {
Future<void> setOnBackgroundMessage(BackgroundMessageHandler handler) async {
_onBackgroundMessage = handler;
if (io.Platform.isAndroid) {
await BackgroundIsolateAndroidPlatform.methodChannel
.invokeMethod(PlatformMethod.pushSetOnBackgroundMessage);
await BackgroundIsolateAndroidPlatform.methodChannel.invokeMethod(
PlatformMethod.pushBackgroundFlutterApplicationReadyOnAndroid);
}
}

Expand Down

0 comments on commit 006bb82

Please sign in to comment.