-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
App crashes on receiving a notification in the foreground, or when clicking a notification that appeared while the app is in the background #3447
Comments
My guess is that if you reach into that .m file inside node_modules and test-hacked the test you found that crashed so it looked just like the one above it, it would work. Here's the one above it and the one you mention: react-native-firebase/packages/messaging/ios/RNFBMessaging/RNFBMessagingSerializer.m Lines 110 to 118 in ff8b1ce
The hypothesis based on the invalid selector error (isEqualToString does not exist on object of type '__NSCFNumber') that it was parsed into a number already instead of a string, and so will likely work like the 'content-available' apsDict value there. Very easy to test at least - please try it and report back? |
Hi @mikehardy, thanks for the quick reply!
Great point, just tested it with the change below and it works
Is this something that I've misconfigured? |
@Ehesp or @Salakar I think this is just a parsing issue, perhaps mutable-content was not checked the same way content-refresh was in your testing so it slipped through? @samkotlove you can see from my hypothesis and question right here that I think it's just a bug. I'd follow this issue and use the fabulous / every project should use it / I am not kidding https://github.com/ds300/patch-package to turn your node_modules hack into a little patch that you can then commit and will be installed correctly every time you install packages until this is resolved for real |
@mikehardy Great suggestion, sure beats my bash scripts that I have for this sort of thing! |
Interesting, when I tested this originally it came through as a string for me which I thought was weird but gave it no further thought, maybe an API difference somewhere - guess we need to check the type also then Will get a fix up on Monday's RC. Thanks for debugging and providing a thorough issue report - makes our life easier |
It worked for me. Thanks for finding and fixing this issue (it got me crazy for the last couple of days). |
I have a similar issue probably connected with this bug. After adding additional data to the notification on the server-side, iOS app crash after receiving new notification (in the foreground or after clicking on a notification while the app is in the background)
|
@samkotlove Hey how did you manage to get notification when app is in foreground? I'm getting notification when my app is in background but not when it's in foreground. |
Still working on it. As @mikehardy recommended in other tickets I’m trying react-native-push-notifications (which just uses @react-native-community/push-notifications-ios under the hood for iOS). There’s a solution I’ve found that has you hide foreground and background pushes and send a local notification when receiving a fcm message. It sort of works but has problems, such as I can’t seem to access data when a user clicks the fake, local notification. I’ll update when i commit to a solution. |
@Nehal-29 After more thought (and reading quite a few old github issues on this repo, on react-native-push-notification, and @react-native-community/push-notification-ios) I'm completely going against what I previously said. The solution is essentially:
If you just want push notifications, that seems to be all that's required. My use case required navigating to certain screens in the app depending on the push notification, so it required a couple additional steps:
The reason you add that property is that the PushService.js (this is the file that handles push notifications, I initialize it in my App.js constructor. There's quite a few people that say this needs to exist outside the react lifecycle, so take this specific implementation with that in mind):
and then in your native code(probably AppDelegate.m):
I haven't finished my android implementation, so it's entirely possible the javascript code may need to change or have different logic depending on the OS. I also haven't done extremely rigorous testing so there may be issues still (i.e. anecdotally,. if the app was force closed it doesn't always seem to trigger notifications). But if those issues seem rare I may deploy a version of this with metrics tracking notifications received versus notifications sent, to determine how well it delivers |
@samkotlove that is great knowledge sharing and matches my experience - for complete control + success always send silent push, handle in messaging, then use a local notification library for control+reaction. The note about differentiating between "notification displayed" and "notification tapped" should be helpful for everyone! |
Not totally related but for anybody reading this in the future, if you're using this library with react-native-push-notification as I described above, do not set the |
Here is patch file for |
- also fixes the condition for adding secrets
Hello 👋, to help manage issues we automatically close stale issues.
|
…e#3701) Currently receiving notifications with images will crash the app on iOS (Fixes invertase#3447, invertase#3616). Patch proposed by @actuosus, thanks to him 🙌 invertase#3447 (comment) [publish]
…e#3701) Currently receiving notifications with images will crash the app on iOS (Fixes invertase#3447, invertase#3616). Patch proposed by @actuosus, thanks to him 🙌 invertase#3447 (comment) [publish]
Issue
When the app is in the foreground, it will crash on receiving a notification. When the app is in the background, it will receive the notification but when clicking it the app crashes. When running from xcode, the following error is shown:
and in crashlytics I see
Based on the above stack trace, the error is being thrown from
RNFBMessagingSerializer.m
and specifically on line 116:When I comment out this check the app doesn't crash (the notifications dont show when the app is in the foreground but Im unable to determine if that's intended behavior). I've tried this on version 6.4.0 and 6.4.1-alpha.0, the problem happens on both.
Project Files
Javascript
Click To Expand
package.json
:firebase.json
for react-native-firebase v6:iOS
Click To Expand
ios/Podfile
:AppDelegate.m
:Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:6.4.0
6.4.1-alpha.0
Firebase
module(s) you're using that has the issue:messaging
TypeScript
?N
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: