Skip to content

Commit 79756b1

Browse files
committed
feat: support android 12
1 parent 70eeb66 commit 79756b1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.cryptoticket.reactnativepushnotification">
3-
3+
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
44
</manifest>

android/src/main/java/com/cryptoticket/reactnativepushnotification/PushNotificationModule.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class PushNotificationModule(reactContext: ReactApplicationContext) : ReactConte
110110
// recreate pending intent
111111
val mainIntent = Intent(PushNotificationBroadcastReceiver.Actions.SHOW_SCHEDULED_NOTIFICATION)
112112
mainIntent.component = ComponentName(reactApplicationContext, getDefaultBroadcastReceiverClassName())
113-
val pendingIntent = PendingIntent.getBroadcast(reactApplicationContext, notificationId, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT)
113+
val pendingIntent = PendingIntent.getBroadcast(reactApplicationContext, notificationId, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
114114
// cancel notification via alarm manager
115115
val alarmManager = reactApplicationContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager
116116
alarmManager.cancel(pendingIntent)
@@ -185,7 +185,7 @@ class PushNotificationModule(reactContext: ReactApplicationContext) : ReactConte
185185
data.entryIterator.forEach {
186186
mainIntent.putExtra(it.key, if (it.value == null) null else it.value.toString())
187187
}
188-
val pendingIntent = PendingIntent.getBroadcast(reactApplicationContext, notificationId, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT)
188+
val pendingIntent = PendingIntent.getBroadcast(reactApplicationContext, notificationId, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
189189

190190
// prepare base notification builder
191191
val builder = NotificationCompat.Builder(reactApplicationContext, channelId)
@@ -231,15 +231,15 @@ class PushNotificationModule(reactContext: ReactApplicationContext) : ReactConte
231231
val openUrlIntent = Intent(PushNotificationBroadcastReceiver.Actions.OPEN_URL)
232232
openUrlIntent.component = ComponentName(reactApplicationContext, getDefaultBroadcastReceiverClassName())
233233
openUrlIntent.putExtra("url", data.getString("url"))
234-
val openUrlPendingIntent = PendingIntent.getBroadcast(reactApplicationContext, 0, openUrlIntent, PendingIntent.FLAG_UPDATE_CURRENT)
234+
val openUrlPendingIntent = PendingIntent.getBroadcast(reactApplicationContext, 0, openUrlIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
235235
builder.setContentIntent(openUrlPendingIntent)
236236
}
237237
}
238238
// on check button click send CLOSE_NOTIFICATION action to broadcast receiver that closes notification
239239
val closeNotificationIntent = Intent(PushNotificationBroadcastReceiver.Actions.CLOSE_NOTIFICATION)
240240
closeNotificationIntent.component = ComponentName(reactApplicationContext, getDefaultBroadcastReceiverClassName())
241241
closeNotificationIntent.putExtra("id", notificationId)
242-
val closeNotificationPendingIntent = PendingIntent.getBroadcast(reactApplicationContext, notificationId, closeNotificationIntent, PendingIntent.FLAG_UPDATE_CURRENT)
242+
val closeNotificationPendingIntent = PendingIntent.getBroadcast(reactApplicationContext, notificationId, closeNotificationIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
243243
remoteViews.setOnClickPendingIntent(R.id.buttonCheck, closeNotificationPendingIntent)
244244
// set notification template
245245
builder.setContent(remoteViews)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cryptoticket/react-native-push-notification",
3-
"version": "1.4.2",
3+
"version": "1.5.0",
44
"description": "React native package that manages push notifications",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)