react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

RN 0.68.2 - Android 12 (API 31) - RNN 4.3.1 - Issues

Open claudiozam opened this issue 4 years ago • 48 comments

Hi, after upgrading to RNN 4.3.1 and targetSdkVersion 31 (Android 12)

I notice some new issues.

Case 1

Dead state (100% dead) or Fake dead state (if I close the app with the android back button) Send 2 notifications Click on one notification message The app opens ok Notifications.getInitialNotification() returns data While the app is open click on the second notification message App will open again (restarting the main activity). Notifications.getInitialNotification() returns no data

Case 2

Dead / Background state Send 1 notification I don't click the notification message I open the App Notifications.events().registerNotificationOpened is executed. (Related issue #872)

Case 3

Background state Click on the notification message App will open again Notifications.getInitialNotification() returns data

react-native-notifications version

4.3.1

react-native version

0.68.2

Enviroment

"dependencies": { "@alessiocancian/react-native-actionsheet": "^3.1.2", "@codler/react-native-keyboard-aware-scroll-view": "2.0.1", "@fortawesome/fontawesome-common-types": "file:./local_fortawesome/fontawesome-common-types", "@fortawesome/fontawesome-svg-core": "file:./local_fortawesome/fontawesome-svg-core", "@fortawesome/free-brands-svg-icons": "file:./local_fortawesome/free-brands-svg-icons", "@fortawesome/pro-light-svg-icons": "file:./local_fortawesome/pro-light-svg-icons", "@fortawesome/pro-regular-svg-icons": "file:./local_fortawesome/pro-regular-svg-icons", "@fortawesome/pro-solid-svg-icons": "file:./local_fortawesome/pro-solid-svg-icons", "@fortawesome/react-native-fontawesome": "file:./local_fortawesome/react-native-fontawesome", "@invertase/react-native-apple-authentication": "^2.2.0", "@react-native-async-storage/async-storage": "^1.17.5", "@react-native-clipboard/clipboard": "^1.10.0", "@react-native-community/art": "^1.2.0", "@react-native-community/audio-toolkit": "^2.0.3", "@react-native-community/datetimepicker": "^3.5.2", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/slider": "^4.2.2", "@react-native-firebase/analytics": "^14.11.0", "@react-native-firebase/app": "^14.11.0", "@react-native-google-signin/google-signin": "^7.2.2", "@react-native-picker/picker": "^2.4.0", "@react-navigation/drawer": "^6.4.1", "@react-navigation/elements": "^1.3.3", "@react-navigation/native": "^6.0.10", "@react-navigation/stack": "^6.2.1", "@types/uuid": "^8.3.4", "axios": "^0.24.0", "chance": "^1.1.8", "color": "^3.1.3", "detox": "^19.7.0", "formik": "^2.2.6", "fsevents": "^2.3.2", "hermes-engine": "^0.11.0", "immutability-helper": "^3.1.1", "link-preview-js": "^2.1.15", "lodash": "^4.17.20", "native-base": "2.15.2", "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "pretty-bytes": "^6.0.0", "randomcolor": "^0.6.2", "react": "17.0.2", "react-native": "0.68.2", "react-native-add-calendar-event": "^4.0.0", "react-native-autolink": "^4.0.0", "react-native-base64": "^0.2.1", "react-native-blob-util": "^0.16.0", "react-native-bootsplash": "^4.1.4", "react-native-calendars": "1.1279.0", "react-native-color-palette": "^2.2.0", "react-native-config": "^1.4.5", "react-native-device-info": "^8.7.0", "react-native-document-picker": "^8.1.0", "react-native-fast-image": "^8.5.4", "react-native-fbsdk-next": "^8.0.5", "react-native-ffmpeg": "^0.5.2", "react-native-file-viewer": "^2.1.5", "react-native-gesture-handler": "^2.4.1", "react-native-gifted-chat": "^0.16.3", "react-native-hide-with-keyboard": "^1.2.1", "react-native-image-crop-picker": "^0.37.3", "react-native-image-zoom-viewer": "^3.0.1", "react-native-inappbrowser-reborn": "^3.5.1", "react-native-iphone-x-helper": "^1.3.1", "react-native-linear-gradient": "^2.5.6", "react-native-loading-spinner-overlay": "^2.0.0", "react-native-localize": "^2.2.1", "react-native-masked-text": "^1.13.0", "react-native-mime-types": "^2.3.0", "react-native-modal": "^13.0.0", "react-native-modal-datetime-picker": "^13.1.2", "react-native-modal-selector": "^2.1.0", "react-native-notifications": "^4.3.0", "react-native-orientation-locker": "^1.5.0", "react-native-permissions": "^3.3.0", "react-native-progress": "^5.0.0", "react-native-push-notification-popup": "^1.6.0", "react-native-rate": "^1.2.4", "react-native-reanimated": "2.8.0", "react-native-render-html": "^6.3.0", "react-native-safe-area-context": "^4.2.2", "react-native-screens": "^3.13.0", "react-native-share": "^7.4.1", "react-native-simple-toast": "^1.1.3", "react-native-spinkit": "^1.5.1", "react-native-svg": "^12.3.0", "react-native-swipe-gestures": "^1.0.5", "react-native-swiper": "^1.6.0", "react-native-toast-message": "^2.1.5", "react-native-vector-icons": "^9.1.0", "react-native-version": "^4.0.0", "react-native-video": "^5.2.0", "react-native-webview": "11.18.2", "react-redux": "^8.0.2", "read-package-json": "^5.0.0", "redux": "^4.2.0", "redux-persist": "^6.0.0", "redux-thunk": "^2.4.1", "rn-placeholder": "^3.0.3", "rollbar-react-native": "^0.9.1", "sanitize-filename": "^1.6.3", "striptags": "^3.1.1", "url": "^0.11.0", "yup": "^0.32.8" }, "resolutions": { "@codler/react-native-keyboard-aware-scroll-view": "2.0.1", "@react-native-community/datetimepicker": "3.5.2" }, "devDependencies": { "@babel/core": "^7.18.2", "@babel/plugin-proposal-class-properties": "^7.17.12", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.17.12", "@babel/plugin-proposal-optional-chaining": "^7.17.12", "@babel/plugin-transform-arrow-functions": "^7.17.12", "@babel/plugin-transform-shorthand-properties": "^7.16.0", "@babel/plugin-transform-template-literals": "^7.18.2", "@babel/preset-typescript": "^7.17.12", "@babel/runtime": "^7.18.3", "@react-native-community/eslint-config": "^3.0.2", "babel-jest": "^28.1.0", "eslint": "^8.16.0", "jest": "^28.1.0", "metro-react-native-babel-preset": "^0.71.0", "properties-reader": "^2.2.0", "react-test-renderer": "17.0.2", "redux-devtools": "3.7.0" },

Tested on a real device (Samsung S10 / S21 - Android 12)

Thanks

claudiozam avatar May 28 '22 23:05 claudiozam

build failed for when minCompileSdk are upraded to 31

aftabameen avatar Jun 02 '22 11:06 aftabameen

@aftabameen this is my build.gradle

    buildToolsVersion = "31.0.0"
    minSdkVersion = 22
    compileSdkVersion = 31
    targetSdkVersion = 31
    googlePlayServicesAuthVersion = "17.0.0"
    kotlinVersion = "1.5.10"
    androidXAnnotation = "1.+"
    androidXBrowser = "1.+"

claudiozam avatar Jun 02 '22 11:06 claudiozam

https://developer.android.com/google/play/requirements/target-sdk#:~:text=Starting%20in%20August%202022%2C%20new,behavioral%20changes%20in%20Android%2012.

Starting in August 2022, new apps must target API level 31 (Android 12). Starting in November 2022, app updates must target API level 31.

claudiozam avatar Jun 20 '22 18:06 claudiozam

Same issue here react-native-notifications version 4.3.1

react-native version 0.68.2

oliviermtl avatar Jul 05 '22 08:07 oliviermtl

any solution

trugdn avatar Jul 18 '22 04:07 trugdn

There was an sdk update which caused the issue. A workaround is to target Android sdk which is less than 31

  compileSdkVersion = 30
  targetSdkVersion = 30

This way it works, but still not compatible with Android 13 where you have to request notification permissions in runtime

artyorsh avatar Aug 01 '22 08:08 artyorsh

There was an sdk update which caused the issue. A workaround is to target Android sdk which is less than 31

  compileSdkVersion = 30
  targetSdkVersion = 30

This way it works, but still not compatible with Android 13 where you have to request notification permissions in runtime

As @claudiozam mentioned SDK 31 will be soon mandatory

https://developer.android.com/google/play/requirements/target-sdk#:~:text=Starting%20in%20August%202022%2C%20new,behavioral%20changes%20in%20Android%2012.

Starting in August 2022, new apps must target API level 31 (Android 12). Starting in November 2022, app updates must target API level 31.

oliviermtl avatar Aug 08 '22 22:08 oliviermtl

For us it seems to be "working" you can take a look at https://github.com/mattermost/mattermost-mobile/tree/gekidou (we use custom notifications)

The downside of it all is that we are using react-native-navigation and every time the app sits in the background tapping a notification it will sort of run the MainActivity again, which is displaying the splash screen and all. We are still looking for a better way of doing this, perhaps a transparent activity of some sort, but I'm no Android developer

enahum avatar Aug 08 '22 22:08 enahum

Is there a fix for this? Or is this library EOL?

Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

List of apks:
[0] '/Users/[USERNAME]/github/[APP]/android/app/build/outputs/apk/release/app-release.apk'
Installation failed due to: 'Failed to commit install session 1735472622 with command cmd package install-commit 1735472622. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1735472622.tmp/base.apk (at Binary XML file line #148): com.wix.reactnativenotifications.fcm.FcmInstanceIdListenerService: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'
Retry
Failed to launch an application on all devices

As stated switching to targetSdkVersion = 30 will work, but new apps can not do that any more as of this month, and old apps wont be able to in 2 months.

This is EOL for this library if it can not be patched to be compliant with android:exported="true" more info here https://developer.android.com/about/versions/12/behavior-changes-12#exported

russmenum avatar Aug 15 '22 16:08 russmenum

For us it seems to be "working" you can take a look at https://github.com/mattermost/mattermost-mobile/tree/gekidou (we use custom notifications)

The downside of it all is that we are using react-native-navigation and every time the app sits in the background tapping a notification it will sort of run the MainActivity again, which is displaying the splash screen and all. We are still looking for a better way of doing this, perhaps a transparent activity of some sort, but I'm no Android developer

Can you run your app on an Android 12 Emulator?

russmenum avatar Aug 15 '22 16:08 russmenum

@russmenum Emulator and real devices no problem

enahum avatar Aug 16 '22 12:08 enahum

@russmenum Emulator and real devices no problem

That is an emulator with API 31+, because it runs fine on API 30-

russmenum avatar Aug 16 '22 13:08 russmenum

We had the same or at least similar issues - the main activity was restarting when notification is clicked, and the notification payload data was wrapped in additional pushNotification object. This fixed it in our case

react-native-notifications+4.3.1.patch

diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
index 90969b2..4c00e69 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
@@ -63,7 +63,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
     @Override
     public void onNewIntent(Intent intent) {
         if (NotificationIntentAdapter.canHandleIntent(intent)) {
-            Bundle notificationData = intent.getExtras();
+            Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
             final IPushNotification notification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationData);
             if (notification != null) {
                 notification.onOpened();
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
index eadf41e..a3f71dd 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
@@ -96,8 +96,7 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade.
         Intent intent = activity.getIntent();
         if (NotificationIntentAdapter.canHandleIntent(intent)) {
             Context appContext = mApplication.getApplicationContext();
-            Bundle notificationData = NotificationIntentAdapter.cannotHandleTrampolineActivity(appContext) ?
-                    NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras();
+            Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
             final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
             if (pushNotification != null) {
                 pushNotification.onOpened();
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java
index 41b4824..4285ac5 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java
@@ -14,17 +14,9 @@ public class NotificationIntentAdapter {
 
     @SuppressLint("UnspecifiedImmutableFlag")
     public static PendingIntent createPendingNotificationIntent(Context appContext, PushNotificationProps notification) {
-        if (cannotHandleTrampolineActivity(appContext)) {
-            Intent mainActivityIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
-            mainActivityIntent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
-            TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(appContext);
-            taskStackBuilder.addNextIntentWithParentStack(mainActivityIntent);
-            return taskStackBuilder.getPendingIntent((int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
-        } else {
-            Intent intent = new Intent(appContext, ProxyService.class);
-            intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
-            return PendingIntent.getService(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT);
-        }
+        Intent intent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
+        intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
+        return PendingIntent.getActivity(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
     }
 
     public static boolean cannotHandleTrampolineActivity(Context appContext) {

You can apply this patch using patch-package

petarstamenkov avatar Sep 01 '22 06:09 petarstamenkov

@petarstamenkov thanks for sharing your progress on that. Could you please share your apps targetSdkVersion and compileSdkVersion? I didn't manage to get the package work with your patch, but what worked for us targeting and compiling for sdk-33, is

diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
index eadf41e..5903e02 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
@@ -17,7 +17,6 @@ import com.wix.reactnativenotifications.core.InitialNotificationHolder;
 import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
 import com.wix.reactnativenotifications.core.notification.IPushNotification;
 import com.wix.reactnativenotifications.core.notification.PushNotification;
-import com.wix.reactnativenotifications.core.notification.PushNotificationProps;
 import com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer;
 import com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer;
 
@@ -96,9 +95,7 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade.
         Intent intent = activity.getIntent();
         if (NotificationIntentAdapter.canHandleIntent(intent)) {
             Context appContext = mApplication.getApplicationContext();
-            Bundle notificationData = NotificationIntentAdapter.cannotHandleTrampolineActivity(appContext) ?
-                    NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras();
-            final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
+            final IPushNotification pushNotification = PushNotification.get(appContext, intent.getExtras());
             if (pushNotification != null) {
                 pushNotification.onOpened();
             }

The above works with package version 4.3.1 and in combination with

compileSdkVersion = 33
targetSdkVersion = 33

Also attaching a video for the most curious 🙂

@DanielEliraz with the patch given, I think the NotificationIntentAdapter.extractPendingNotificationDataFromIntent should be adjusted depending on BuildConfig fields. The thing to do is to collect what people target and compile

artyorsh avatar Sep 05 '22 15:09 artyorsh

@artyorsh not work

camboYY avatar Sep 20 '22 04:09 camboYY

final IPushNotification pushNotification = PushNotification.get(appContext, intent.getExtras());

This works for us with compileSdkVersion=33 targetSdkVersion = 32

and RN 0.70

oliviermtl avatar Sep 21 '22 07:09 oliviermtl

None of the patches worked with the app closed. This one worked with the app in background https://github.com/wix/react-native-notifications/issues/874#issuecomment-1233798966

  • App closed
  • Receive a push notification
  • Open the app by tapping the push notification
  • Move the app to background (home or back button)
  • Open from app icon
  • Notifications.events().registerNotificationOpened is going to run again

I can help testing, but I'm no Android dev to work on a fix.

diegolmello avatar Oct 14 '22 14:10 diegolmello

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Nov 19 '22 14:11 stale[bot]

None of the patches worked with the app closed. This one worked with the app in background #874 (comment)

  • App closed
  • Receive a push notification
  • Open the app by tapping the push notification
  • Move the app to background (home or back button)
  • Open from app icon
  • Notifications.events().registerNotificationOpened is going to run again

I can help testing, but I'm no Android dev to work on a fix.

I think you need to open an activity directly to support opening a notification when app is closed. Here is the PR that show how they fixed it for the Notifee library https://github.com/invertase/notifee/pull/301

hubastard avatar Nov 23 '22 21:11 hubastard

We had the same or at least similar issues - the main activity was restarting when notification is clicked, and the notification payload data was wrapped in additional pushNotification object. This fixed it in our case

react-native-notifications+4.3.1.patch

diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
index 90969b2..4c00e69 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
@@ -63,7 +63,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
     @Override
     public void onNewIntent(Intent intent) {
         if (NotificationIntentAdapter.canHandleIntent(intent)) {
-            Bundle notificationData = intent.getExtras();
+            Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
             final IPushNotification notification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationData);
             if (notification != null) {
                 notification.onOpened();
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
index eadf41e..a3f71dd 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java
@@ -96,8 +96,7 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade.
         Intent intent = activity.getIntent();
         if (NotificationIntentAdapter.canHandleIntent(intent)) {
             Context appContext = mApplication.getApplicationContext();
-            Bundle notificationData = NotificationIntentAdapter.cannotHandleTrampolineActivity(appContext) ?
-                    NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras();
+            Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
             final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
             if (pushNotification != null) {
                 pushNotification.onOpened();
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java
index 41b4824..4285ac5 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java
@@ -14,17 +14,9 @@ public class NotificationIntentAdapter {
 
     @SuppressLint("UnspecifiedImmutableFlag")
     public static PendingIntent createPendingNotificationIntent(Context appContext, PushNotificationProps notification) {
-        if (cannotHandleTrampolineActivity(appContext)) {
-            Intent mainActivityIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
-            mainActivityIntent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
-            TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(appContext);
-            taskStackBuilder.addNextIntentWithParentStack(mainActivityIntent);
-            return taskStackBuilder.getPendingIntent((int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
-        } else {
-            Intent intent = new Intent(appContext, ProxyService.class);
-            intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
-            return PendingIntent.getService(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT);
-        }
+        Intent intent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
+        intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
+        return PendingIntent.getActivity(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
     }
 
     public static boolean cannotHandleTrampolineActivity(Context appContext) {

You can apply this patch using patch-package

I can confirm that the patch works for me.

RN 0.68.3
compileSdkVersion = 31
targetSdkVersion = 31
react-native-notifications 4.3.3

Targeting SDK to 33 didn't help.

anisimov74 avatar Nov 25 '22 14:11 anisimov74