-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(firebase_messaging): roadmap rework #4012
Conversation
Co-authored-by: ehesp <[email protected]> Co-authored-by: Helena Ford <[email protected]> Co-authored-by: Kirsty Williams <[email protected]> Co-authored-by: Salakar <[email protected]>
packages/firebase_messaging/firebase_messaging/example/test_driver/instance_e2e.dart
Outdated
Show resolved
Hide resolved
packages/firebase_messaging/firebase_messaging/example/test_driver/instance_e2e.dart
Outdated
Show resolved
Hide resolved
packages/firebase_messaging/firebase_messaging/example/lib/permissions.dart
Outdated
Show resolved
Hide resolved
…ace/lib/src/utils.dart Co-authored-by: Helena Ford <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For anyone else coming across this PR with an issue or coming from a linked issue and want to discuss this upcoming version, please see the discussion post: #4023 |
Hi |
@swapnens That's not possible, not with FCM at least. You could try hacking your way around by using some 3rd party library to force open an app in the background handler but no clue if that would work. |
You can call native on the background handler, so you could do something like trigger an app launch via an Intent (Android): https://stackoverflow.com/questions/3872063/how-to-launch-an-activity-from-another-application-in-android That should work, however requires native code or using a 3rd party library. It's also not guaranteed trigger the background handler if the app is forced quit etc. |
Co-authored-by: @Ehesp
Co-authored-by: @helenaford
Co-authored-by: @kirstywilliams
Co-authored-by: @Salakar
For anyone else coming across this PR with an issue or coming from a linked issue and want to discuss this upcoming version, please see the discussion post: #4023
A
firebase_messaging
dev release with these changes is available -8.0.0-dev.3
.Description
The Firebase Messaging package has has a full overhaul as part of our roadmap (#2582). The package is now federated to allow integration with other platforms, along with upgrading underlying SDK versions. We've also added lots of features which can be seen below, however notably the biggest changes are:
FirebaseMessaging
BREAKING:
configure()
has been removed in favor of calling specific static methods which return Streams.Why?: The previous implementation of
configure()
caused unintended side effects if called multiple times (either to register a different handler, or remove handlers). This change allows developers to be more explicit about registering handlers and removing them without effecting others via Streams.DEPRECATED: Calling
FirebaseMessaging()
has been deprecated in favor ofFirebaseMessaging.instance
&FirebaseMessaging.instanceFor()
.DEPRECATED:
requestNotificationPermissions()
has been deprecated in favor ofrequestPermission()
.DEPRECATED:
deleteInstanceID()
has been deprecated in favor ofdeleteToken()
.DEPRECATED:
autoInitEnabled()
has been deprecated in favor ofisAutoInitEnabled
.NEW: Added support for
isAutoInitEnabled
as a synchronous getter.NEW: Added support for
getInitialMessage()
.This API has been added to detect whether a messaging containing a notification has caused the application to be opened via users interaction.
NEW: Added support for
deleteToken()
.NEW: Added support for
getToken()
.NEW: [Apple] Added support for
getAPNSToken()
.NEW: [Apple] Added support for
getNotificationSettings()
. SeeNotificationSettings
below.NEW: [Apple] Added support for
requestPermission()
. SeeNotificationSettings
below.New permissions such as
carPlay
,crtiticalAlert
,announcement
are now supported.NEW: [Android] Added support for
sendMessage()
.The
sendMessage()
API enables support for sending FCM payloads back to a custom server from the device.NEW - [Android] When receiving background messages on the separate background Dart executor whilst in debug, you should now see flutter logs and be able to debug/add breakpoints your Dart background message handler.
NEW: [Apple] Added support for
setForegroundNotificationPresentationOptions()
.By default, iOS devices will not show notifications in the foreground. Use this API to override the defaults. See documentation for Android foreground notifications.
NEW - [Android] Firebase Cloud Messages that contain a notification are now always sent to Dart irregardless of whether the app was in the foreground or background. Previously, if a message came through that contained a notification whilst your app was in the foreground then FCM would not notify the plugin messaging service of the message (and subsequently your handlers in Dart) until the user interacted with it.
Event handling
Event handling has been reworked to provide a more intuitive API for developers. Foreground based events can how be accessed via Streams:
FirebaseMessaging.onMessage
Returns a Stream that is called when an incoming FCM payload is received whilst the Flutter instance is in the foreground, containing a [RemoteMessage].FirebaseMessaging.onMessageOpenedApp
Returns a [Stream] that is called when a user presses a notification displayed via FCM. This replaces the previousonLaunch
andonResume
handlers.FirebaseMessaging.onBackgroundMessage()
Sets a background message handler to trigger when the app is in the background or terminated.DEPRECATED:
IosNotificationSettings
Usage of the
IosNotificationSettings
class is now deprecated (currently used with the now deprecatedrequestNotificationPermissions()
method).Instead of this class, use named arguments when calling
requestPermission()
and read the permissions back viaNotificationSettings
.NEW
NotificationSettings
The
NotificationSettings
class is returned from calls torequestPermission()
andgetNotificationSettings()
. It contains information such as the authorization status, along with platform specific settings.NEW:
RemoteMessage
Incoming FCM payloads are now represented as a
RemoteMessage
rather than a rawMap
.NEW:
RemoteNotification
When a message includes a notification payload, the results are returned as a
RemoteNotification
rather than a rawMap
.NEW:
BackgroundMessageHandler
,AppleNotificationSetting
,AppleShowPreviewSetting
,AuthorizationStatus
,AndroidNotificationPriority
,AndroidNotificationVisibility
Additional types are available throughout messaging to aide with the latest changes.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
).This will ensure a smooth and quick review process. Updating the
pubspec.yaml
and changelogs is not required.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
Related Issues
FlutterFirebaseMessagingService.setPluginRegistrant
#3757PRs
api
#1983README.md
. #3457firebase_core
plugin #3071