From ae55ce72cc2f84956993282ac1e72be945f2bc55 Mon Sep 17 00:00:00 2001 From: Tyler-Larkin Date: Wed, 4 Dec 2024 14:07:58 -0800 Subject: [PATCH] chore(notifications): updated native pigeon breaking changes --- .../AmplifyLifecycleObserver.kt | 2 +- .../AmplifyPushNotificationsPlugin.kt | 4 ++-- .../amplify_push_notifications/NoOpVoidResult.kt | 10 ++++++++++ .../PushNotificationBackgroundService.kt | 5 +++-- .../PushNotificationFirebaseMessagingService.kt | 5 +++-- 5 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/NoOpVoidResult.kt diff --git a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyLifecycleObserver.kt b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyLifecycleObserver.kt index 8a750e6bd7..1faae83bdc 100644 --- a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyLifecycleObserver.kt +++ b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyLifecycleObserver.kt @@ -17,7 +17,7 @@ class AmplifyLifecycleObserver : DefaultLifecycleObserver { // Only set launchNotification to null when app resumes from background. if (!isAppLaunch) { AmplifyPushNotificationsPlugin.launchNotification = null - AmplifyPushNotificationsPlugin.flutterApi!!.nullifyLaunchNotification { } + AmplifyPushNotificationsPlugin.flutterApi!!.nullifyLaunchNotification(NoOpVoidResult()) } refreshToken() isAppLaunch = false diff --git a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyPushNotificationsPlugin.kt b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyPushNotificationsPlugin.kt index 731d93fd50..dfc4b3e4e0 100644 --- a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyPushNotificationsPlugin.kt +++ b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/AmplifyPushNotificationsPlugin.kt @@ -104,7 +104,7 @@ class AmplifyPushNotificationsPlugin( // Force init stream handlers when the app is opened from killed state so old handlers are removed. StreamHandlers.initStreamHandlers(true) StreamHandlers.initEventChannels(mainBinaryMessenger!!) - PushNotificationsHostApi.setup(mainBinaryMessenger!!, this) + PushNotificationsHostApi.setUp(mainBinaryMessenger!!, this) flutterApi = PushNotificationsFlutterApi(mainBinaryMessenger!!) applicationContext = flutterPluginBinding.applicationContext sharedPreferences = applicationContext.getSharedPreferences( @@ -117,7 +117,7 @@ class AmplifyPushNotificationsPlugin( mainBinaryMessenger = null _flutterEngineCache.clear() StreamHandlers.deInit() - PushNotificationsHostApi.setup(binding.binaryMessenger, null) + PushNotificationsHostApi.setUp(binding.binaryMessenger, null) flutterApi = null } diff --git a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/NoOpVoidResult.kt b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/NoOpVoidResult.kt new file mode 100644 index 0000000000..1f64b0c8db --- /dev/null +++ b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/NoOpVoidResult.kt @@ -0,0 +1,10 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.amazonaws.amplify.amplify_push_notifications + +class NoOpVoidResult : PushNotificationsHostApiBindings.VoidResult { + override fun success() {} + + override fun error(error: Throwable) {} +} diff --git a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationBackgroundService.kt b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationBackgroundService.kt index f4a73b1984..c4ce14bfa8 100644 --- a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationBackgroundService.kt +++ b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationBackgroundService.kt @@ -134,8 +134,9 @@ class PushNotificationBackgroundService : JobIntentService(), MethodChannel.Meth intent.extras?.let { bundle -> bundle.getNotificationPayload()?.let { AmplifyPushNotificationsPlugin.flutterApi!!.onNotificationReceivedInBackground( - it.toWritableMap() - ) {} + it.toWritableMap(), + NoOpVoidResult() + ) } } } diff --git a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationFirebaseMessagingService.kt b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationFirebaseMessagingService.kt index 24f7501c58..caef8f7124 100644 --- a/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationFirebaseMessagingService.kt +++ b/packages/notifications/push/amplify_push_notifications/android/src/main/kotlin/com/amazonaws/amplify/amplify_push_notifications/PushNotificationFirebaseMessagingService.kt @@ -100,8 +100,9 @@ class PushNotificationFirebaseMessagingService : FirebaseMessagingService() { } else { val notificationPayload = payload.toWritableMap() AmplifyPushNotificationsPlugin.flutterApi!!.onNotificationReceivedInBackground( - notificationPayload - ) {} + notificationPayload, + NoOpVoidResult() + ) } }