forked from phonegap/phonegap-plugin-push
-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android): support targetSdkVersion >= 31 (Android 12) (#185)
* feat(android): update Firebase Messaging to 23 This is needed for compatibility with targetSdkVersion>=31. Without it, push messages cause a crash on Android 12 due to missing FLAG_MUTABLE/FLAG_IMMUTABLE on PendingIntent[0], notification trampoline issue, and possibly other such reasons. Note that Firebase has removed the FirbaseInstanceId class in favor of FirbaseInstallations. To restore it for now, add the firebase-iid dependency, see [2]. [0] https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability [1] https://developer.android.com/about/versions/12/behavior-changes-12#notification-trampolines [2] https://firebase.google.com/support/release-notes/android#messaging_v22-0-0 * refactor(android): merge PushInstanceIDListenerService into FCMService Since 1ae3428, when `PushInstanceIDListenerService` was changed away from the deprecated `FirebaseInstanceIdService` to use `FirebaseMessagingService::onNewToken`, there is no longer a need to use a separate service anymore. Further, the `INSTANCE_ID_EVENT` intent filter is not needed. * refactor(android): remove unneeded indirection on onNewToken The callback gets the new token already, there is no need to fetch it again. * refactor(android): avoid using deprecated InstanceId methods These have been deprecated in recent firebase-messaging releases. * fix(android): specify pending intent mutability for targetSdkVersion>=31 See: https://developer.android.com/guide/components/intents-filters#DeclareMutabilityPendingIntent * fix(android): improve the error handling around Tasks.await Tasks.await throws ExecutionException so it needs to be unwrapped for the existing error handling to work, otherwise an IOException causes the app to crash.
- Loading branch information
Showing
4 changed files
with
54 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/android/com/adobe/phonegap/push/PushInstanceIDListenerService.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters