Skip to content

Commit

Permalink
(android) fix no notifications on Android 12 and above, Non-fatal Exc…
Browse files Browse the repository at this point in the history
…eption: java.lang.IllegalArgumentException
  • Loading branch information
ollm committed Jul 15, 2022
1 parent 2b56f92 commit 528228f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/android/FirebasePluginMessagingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ private void sendMessage(RemoteMessage remoteMessage, Map<String, String> data,
if (showNotification) {
Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
intent.putExtras(bundle);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);

// Only add on platform levels that support FLAG_IMMUTABLE
final int flag = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent, flag);

// Channel
if(channelId == null || !FirebasePlugin.channelExists(channelId)){
Expand All @@ -250,7 +253,6 @@ private void sendMessage(RemoteMessage remoteMessage, Map<String, String> data,
}



NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
notificationBuilder
.setContentTitle(title)
Expand Down

0 comments on commit 528228f

Please sign in to comment.