question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS] `onNotification` never called if the app was in "killed" status and received a remote notification.

See original GitHub issue

Bug

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

  1. Clone zo0r/react-native-push-notification.
  2. cd to example dir
  3. Run npm install and npm run pod-install.
  4. Run npm run ios to start the app with simulator as usual.
  5. After the app launched on iOS simulator, kill the app. (Cmd + Shift + H x 2, and swipe up the app).
  6. Create .apns file like below.
{
    "Simulator Target Bundle": "org.reactjs.native.example.example",
    "aps":{
        "alert":"Hello World",
        "sound":"default",
    }
}
  1. Drag and drop the.apns file to the simulator.
  2. You will see the notification bar and tap it.
  3. 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:

  1. Same behavior with v5.1.1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

4reactions
Dallas62commented, Sep 29, 2020

Hi @gki Please refer to the iOS library for this: https://github.com/react-native-community/push-notification-ios Regards

2reactions
gkicommented, Sep 30, 2020

@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 to react-native-community/push-notification-ios -> OK

  • Correctly setup iOS project by following Readme of react-native-community/push-notification-ios -> OK スクリーンショット 2020-09-30 10 27 11

  • Update 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 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,

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found