[iOS] `onNotification` never called if the app was in "killed" status and received a remote notification.
See original GitHub issueBug
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.
Environment info
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
Steps To Reproduce
- Clone
zo0r/react-native-push-notification
. - cd to
example
dir - Run
npm install
andnpm run pod-install
. - Run
npm run ios
to start the app with simulator as usual. - After the app launched on iOS simulator, kill the app. (Cmd + Shift + H x 2, and swipe up the app).
- Create
.apns
file like below.
{
"Simulator Target Bundle": "org.reactjs.native.example.example",
"aps":{
"alert":"Hello World",
"sound":"default",
}
}
- Drag and drop the
.apns
file to the simulator. - You will see the notification bar and tap it.
- The example app will be launched, but the
Note:
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:
- Same behavior with v5.1.1.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8
Top Results From Across the Web
Handle remote notifications when app is killed
We have a server that sends remote notifications to iOS devices by using APNS. ... When the app is killed, DidReceiveRemoteNotification() is not...
Read more >iOS push notification: how to detect if the user tapped on ...
To check whether user has tapped, or app is in background or is active, ... Modes" > "Remote notifications" checked == YES, tap...
Read more >Notifications Not Shown - Mobile Push
When an app is in a Force Stopped / Force Killed state most events including FCM messages for push notifications will not be...
Read more >Notifications - Expo Documentation
To set up your Android app to receive push notifications using your own FCM ... If you are not using Expo's push notification...
Read more >Push Notifications Capacitor Plugin API
Android. This plugin does support data-only notifications, but will NOT call pushNotificationReceived if the app has been killed. To handle this scenario, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @gki Please refer to the iOS library for this: https://github.com/react-native-community/push-notification-ios Regards
@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.
In
package.json
, have a dependency toreact-native-community/push-notification-ios
-> OKCorrectly setup iOS project by following Readme of
react-native-community/push-notification-ios
-> OKUpdate
AppDelegate
-> OK.Checked changelog of
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,