-
Notifications
You must be signed in to change notification settings - Fork 767
RN 0.68.2 - Android 12 (API 31) - RNN 4.3.1 - Issues #874
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
Comments
build failed for when minCompileSdk are upraded to 31 |
@aftabameen this is my build.gradle
|
Starting in August 2022, new apps must target API level 31 (Android 12). |
Same issue here react-native version |
any solution |
There was an sdk update which caused the issue. A workaround is to target Android sdk which is less than 31
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
|
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 |
Is there a fix for this? Or is this library EOL?
As stated switching to This is EOL for this library if it can not be patched to be compliant with |
Can you run your app on an Android 12 Emulator? |
@russmenum Emulator and real devices no problem |
That is an emulator with API 31+, because it runs fine on API 30- |
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. react-native-notifications+4.3.1.patch
You can apply this patch using patch-package |
@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
Also attaching a video for the most curious 🙂 @DanielEliraz with the patch given, I think the |
@artyorsh not work |
This works for us with and RN 0.70 |
None of the patches worked with the app closed.
I can help testing, but I'm no Android dev to work on a fix. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
I think you need to open an activity directly to support opening a notification when app is closed. |
I can confirm that the patch works for me.
Targeting SDK to 33 didn't help. |
@anisimov74 How did you get a **ERROR** Failed to apply patch for package react-native-notifications at path
node_modules/react-native-notifications |
|
any luck , RN 66.1 and 4.3.3 for react-native-notifications. Is there a working patch that allows notifications to work when android app is fully terminated ? |
@petarstamenkov solved for me v4.3.3 |
I'm on 4.3.3. My app targets API level 33 though, which might be the cause of my issues (?): Everything works fine for me <= Android 11 on emulator and real device. For Android 12 and 13 I receive the FCM notifications on the emulator but clicking them does nothing. Works perfectly fine on Android 11 and below and triggers all the handlers as expected. Anyone have any idea what I could be doing wrong? Been banging my head against the wall the past week trying all the different patches above etc. Would appreciate some guidance. Much appreciated! |
Just piling on here to mention that the patch @diegolmello mentioned is working well on v4.3.3: |
For those who searching for solution of getInitialNotification -> null problem on Android (when you open closed app by tapping on notification): in my case, the problem was that i have separate Activity for splash screen with intent-filters in it To solve it you can remove splash activity from manifest and make splash on RN side or use something like react-native-bootsplash |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
A combination of #874 (comment) and #906 (comment) fixed my notification handling issues. RN 0.68.5 EDIT: we have an issue on android api v8 with something in our patch causing a crash |
@bhandanyan-nomad would you mind sharing a fork with the changes? |
I managed to get it to work with the patch below. I tested it on physical devices running on Android 13 and Android 9. react-native-notifications+4.3.3.patch
The key change compared to patch provided by the RocketChat is that I modified the implementation of the public static Bundle extractPendingNotificationDataFromIntent(Intent intent) {
Bundle notificationBundle = intent.getBundleExtra(PUSH_NOTIFICATION_EXTRA_NAME);
if (notificationBundle != null) {
return notificationBundle;
} else {
return intent.getExtras();
}
} EDIT If anyone would like to use it without dealing with patches, I created a fork with the fix. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
The issue has been closed for inactivity. |
@claudiozam version 5.0.0 was released with the additions suggested here. Can you verify it's OK? |
@DanielEliraz thanks for your excellent work. I am not using the library any more in my apps. Long live and prosperity!! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
The issue has been closed for inactivity. |
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
The text was updated successfully, but these errors were encountered: