This issue is only on iOS.
On iOS, v5.1.1 called onNotification() when a remote notification arrived even if the app was in "killed" state. (e.g. the user killed the app on purpose.)
However, from v6.0.0, I found that onNotification() is not called int the same situation and it can be reproduced with the example app of this repo. See the Steps To Reproduce section for details.
react-native info output:
System:
OS: macOS 10.15.6
CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
Memory: 28.91 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.18.2 - ~/.nvm/versions/node/v12.18.2/bin/node
Yarn: Not Found
npm: 6.14.5 - ~/.nvm/versions/node/v12.18.2/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 29, 30
Build Tools: 29.0.2, 30.0.2
System Images: android-28 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 11.7/11E801a - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_265 - /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
react-native-macos: Not Found
Library version:
v5.1.1 : onNotification() called
v6.0.0 : onNotification() NOT called
The latest of dev branch : onNotification() NOT called
zo0r/react-native-push-notification.example dirnpm install and npm run pod-install.npm run ios to start the app with simulator as usual..apns file like below.{
"Simulator Target Bundle": "org.reactjs.native.example.example",
"aps":{
"alert":"Hello World",
"sound":"default",
}
}
.apns file to the simulator.From Xcode 11.4, we can test a remote notification on iOS simulator.
https://developer.apple.com/documentation/xcode-release-notes/xcode-11_4-release-notes
Describe what you expected to happen:
Hi @gki
Please refer to the iOS library for this:
https://github.com/react-native-community/push-notification-ios
Regards
Also, if the issue happen after upgrading the library, please refer to:
https://github.com/zo0r/react-native-push-notification/blob/master/CHANGELOG.md
@react-native-community/push-notification-ios is now a peerDependency, please make sure that you installed this library with NPM or YARN.
@Dallas62 Thanks for your quick response.
I checked your links and reviewed the example app files of zo0r/react-native-push-notification/, but I cannot find any missing or wrong settings.
Here are what I checked. Everything seems to be already set up correctly.
package.json, have a dependency to react-native-community/push-notification-ios -> OKreact-native-community/push-notification-ios -> OK
AppDelegate -> OK. zo0r/react-native-push-notification. -> OK (In my understanding, it should be OK for iOS if there is a dependency to react-native-community/push-notification-ios)Do you have any thought for other suspicious setting or code?
Please let me know if there are anything I can help to check.
Thanks,
I had this exact issue after upgrading to 6.1.1. A few things I needed to do to fix it.
I read a few posts about issues with react-native-splash-screen, which we use so I thought that could be it.
To fix that I set popInitialNotification to false during configure.
Then called PushNotification.popInitialNotification once I was sure our app was ready to handle the notification.
That still didn't work. Then I found that PushNotification.popInitialNotification will not return the notification if you deployed a debug build. Need to deploy a release build.
The only issue I'm still facing is that for iOS onNotification and popInitialNotification return a different format.
In one it is something like {... message: "message body", title: "message title" ... } and in the other it is {... message: {body: "message body", title: "message title"} ...}.
@gki when you mentioned "killed", do you mean user double tap on home button and swipe the app away?
@TommyLeong Yes. That's right.
What I've realized recently is, in "killed" state... none of the delegate and method will get trigger until user launch the app again. Notification banner could appear, but no further background action can be executed. I posted a question at Stackoverflow yesterday
+1
Most helpful comment
@Dallas62 Thanks for your quick response.
I checked your links and reviewed the example app files of
zo0r/react-native-push-notification/, but I cannot find any missing or wrong settings.Here are what I checked. Everything seems to be already set up correctly.
package.json, have a dependency toreact-native-community/push-notification-ios-> OKreact-native-community/push-notification-ios-> OKAppDelegate-> OK.zo0r/react-native-push-notification. -> OK (In my understanding, it should be OK for iOS if there is a dependency toreact-native-community/push-notification-ios)Do you have any thought for other suspicious setting or code?
Please let me know if there are anything I can help to check.
Thanks,