Skip to content

Commit

Permalink
fix(Android): Fix crash when targeting SDK 31+
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh-hannurkar committed Dec 19, 2022
1 parent 009a424 commit 4eee7e7
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.asterinet.react.bgactions;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
Expand All @@ -23,6 +24,7 @@ final public class RNBackgroundActionsTask extends HeadlessJsTaskService {
public static final int SERVICE_NOTIFICATION_ID = 92901;
private static final String CHANNEL_ID = "RN_BACKGROUND_ACTIONS_CHANNEL";

@SuppressLint("WrongConstant")
@NonNull
public static Notification buildNotification(@NonNull Context context, @NonNull final BackgroundTaskOptions bgOptions) {
// Get info
Expand All @@ -40,7 +42,7 @@ public static Notification buildNotification(@NonNull Context context, @NonNull
}
final PendingIntent contentIntent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);
} else {
contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
}
Expand Down

0 comments on commit 4eee7e7

Please sign in to comment.