-
Notifications
You must be signed in to change notification settings - Fork 766
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
Android 11 and above crashing on notification open #835
Comments
same here. Anyone already fixed this issue ? |
@StefanLuecke , @MajkellVZ , please see if it's fixed in 4.2.4 |
@DanielEliraz the error persists |
@DanielEliraz Seems to work for me ... will test it on multiple devices tomorrow. Thx for your awesome work! |
for me it works when the app is killed but not when it's in background, but so did with the last version |
lowered the |
@MajkellVZ Need to find a way to solve it also in |
can you please share your solution without the need to lower the sdk to 30? |
@DanielEliraz This problem persists for me in 4.2.4 with Android 12 and target SDK 31. I recommend keeping the issue open until this package works with > 30. |
Same for our app running on Android 12 devices with targetSDKVersion set to
Sample stack trace. From the 100+ reports I can see it only happens at getInitialNotification calls from "cold boots", if the app is already running it seems to open fine:
|
The only solution I found was to roll back to SDK 30. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Hmm, @DanielEliraz I'm still experiencing this on 4.3.1 when opening a push notification as a cold boot with
|
@DanielEliraz So far having the same results as @hankhester with the new 4.3.1 version |
After some monitoring I have to retract my earlier statement that this was fixed, I encounter crashes with the similar stack trace as @hankhester reported here. So, @DanielEliraz just to prevent these unhandled crashes, would it be possible to patch the`notifiyOpenedToJS method to include a try...catch statement? From: Lines 208 to 213 in a18a593
to private void notifyOpenedToJS() {
Bundle response = new Bundle();
try {
response.putBundle("notification", mNotificationProps.asBundle());
} catch (NullPointerException e) {
Log.e(LOGTAG, "notifyOpenedToJS: Null pointer exception");
} Just like you did in #835? Line 81 in f7928d4
|
Using patch-package you can apply this patch.. it seems to have worked for me: |
@DanielEliraz the issue still exist in v4.3.1 unfortunately. We were that unlucky project who sent ~1k push notifications to users and got ~200 crash reports same day Android 11 and above | RN 0.68.2 | Logs |
Why is this issue closed when the crash is still persisting? |
Same here, still getting crashes with this error |
@DanielEliraz Kindly, can you re-open this issue as it is still happening to me on Android 11 and above. |
Okay, this took way too long, but I got things working with targetSdkVersion 31. I'm also on RN 68.2. There are a few places things could be going wrong for everyone. First, you need to run this patch: #874 (comment) Next, you need to make sure your AndroidManifest.xml handles both deeplinks and universal links if you plan on using both. The structure was changed in Android 12 due to security stuff and now you need separate intents for each type of link (example:// and https://www.example.com). Here's an example from my app. The two schemes I use are deep links: https://www.pebbleclimbing.com and app links: pebble://
Next, when setting stuff up, you need to create a channel on app startup. See here in the docs: https://wix.github.io/react-native-notifications/api/android-api#setnotificationchannel Now, if you want to have foreground notifications, you need to duplicate the incoming notification as a local notification outlined here: #869 (comment) But, this doesn't work because we're going to be sending a channel id with our remote notifications as well (remote notifications won't open the app without it). So, instead of checking for lack of a channel id to see if you need to create a duplicated local notification, add some sort of boolean to the notification when duplicating it for the foreground notification. ex:
Finally, when you send the notification from the server, you need to send the channel id with the data so that it will open your app. I'm using amazon pinpoint and my raw message data structure looks like the following, but yours might be different and need some alternate massaging. This structure is pretty important. If I added anything outside the data object, the notification would not open the app if it was in the background/killed :
Also, if your app is killed, you need to get the notification using getInitialNotification: https://wix.github.io/react-native-notifications/api/general-api/#getinitialnotification Hopefully this helps y'all. This library does work for Android 13, but there are a lot of gotchas. |
@DanielEliraz we're still experiencing this on 4.3.2 (no patches) |
Some members of my team are also experiencing this on 4.3.2, although it might be something device specific, as for others the bug has been fixed. This patch seemed to work for those who are now having issues with 4.3.2: |
Tried the solution provided by @Vednus and it doesn't crash and I think that's mostly because of #835 (comment) but now when opening the notification it doesn't redirect to the desired screen. |
this is enough to target SDK 31 without any crashes |
Also experience this when the app is in the background or killed state. |
RN 0.71 and Android 11 API 30 still has problems. Close the app, receive a notification, open notification and crashes. Applied the patch, however the notification is not being correctly handled, can't retrieve the information. |
@MajkellVZ your patch worked for me!! <3 |
i have the same problem, any fix on this? |
Same crash |
same problem |
still same issue appear in 4.3.3 and RN 0.73 and android version 11(30) and above ! |
The app crashes while opening the notification and shows the following message
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.os.Bundle.clone()' on a null object reference
currently using version 4.2.3
The text was updated successfully, but these errors were encountered: