-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Update push notification to support Android SDK 31+ #10914
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, discussed gradle wrappers offline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two questions.
@@ -78,7 +81,7 @@ private PendingIntent toScheduleNotificationIntent(Bundle bundle) { | |||
notificationIntent.putExtra(RNPushNotificationPublisher.NOTIFICATION_ID, notificationID); | |||
notificationIntent.putExtras(bundle); | |||
|
|||
return PendingIntent.getBroadcast(context, notificationID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); | |||
return PendingIntent.getBroadcast(context, notificationID, notificationIntent, getPendingIntentFlags()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be getActivity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not update these as our library does not support scheduled notifications at this time despite including this underlying native code
@@ -353,16 +353,11 @@ public void sendToNotificationCentre(Bundle bundle) { | |||
// Add "action" for later identifying which button gets pressed. | |||
bundle.putString("action", action); | |||
actionIntent.putExtra("notification", bundle); | |||
PendingIntent pendingActionIntent = PendingIntent.getBroadcast(context, notificationID, actionIntent, | |||
PendingIntent.FLAG_UPDATE_CURRENT); | |||
PendingIntent pendingActionIntent = PendingIntent.getBroadcast(context, notificationID, actionIntent, getPendingIntentFlags()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be getActivity
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here in that we don't really support actions ootb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Description of changes
Android 12 included two behavior changes which affected Amplify push notification:
PendingIntent
s now require mutability flag to be specifiedThis PR updates Amplify push notification to address these two behavioral changes:
PendingIntents
now include mutability flag (set to immutable)This PR also cleans up the state of the Android artifacts checked into this repo to remove the
.gradle/
folder but include the gradle wrapper.Issue #, if available
#10118May not actually be relevant#10252
Description of how you validated changes
Tested locally with sample Android apps targeting < SDK 31 and >= SDK 31
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.