Skip to content
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

Fix intent flag #595

Merged
merged 1 commit into from
May 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PilllFirebaseMessagingService: FirebaseMessagingService() {
val mainActivityIntent = Intent(this, MainActivity::class.java).also {
it.flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
val openAppPendingIntent = PendingIntent.getActivity(this,1, mainActivityIntent, PendingIntent.FLAG_CANCEL_CURRENT)
val openAppPendingIntent = PendingIntent.getActivity(this, 1, mainActivityIntent, PendingIntent.FLAG_IMMUTABLE)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PendingIntentのフラグはFLAG_IMMUATBLEにする必要があった

ref: https://star-zero.medium.com/pendingintent%E3%81%AEflag-immutable%E3%81%A8flag-mutable-d72bf7c90135

val title = remoteMessage.data["title"]
val body = remoteMessage.data["body"]
val builder = NotificationCompat.Builder(this, getString(R.string.reminder_channel_id))
Expand All @@ -41,7 +41,7 @@ public class PilllFirebaseMessagingService: FirebaseMessagingService() {
action = "PILL_REMINDER"
}
val pendingIntent: PendingIntent =
PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT)
PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)

builder.addAction(0, "飲んだ", pendingIntent)
}
Expand Down