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.

PushNotificationIOS conflicting docs AND localNotification event is not firing after remote notif SDK integration

See original GitHub issue

React Native version:

    System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 453.62 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.15.0 - /usr/local/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
    Android SDK:
      API Levels: 24, 26, 27, 28, 29
      Build Tools: 26.0.2, 27.0.3, 28.0.3, 29.0.0
      System Images: android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom
      Android NDK: 14.1.3816874
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.60.5 => 0.60.5
  npmGlobalPackages:
    create-react-native-app: 2.0.2
    react-native-cli: 2.0.1

Steps To Reproduce

  1. git clone git@github.com:geektimecoil/react-native-onesignal
  2. cd react-native-onesignal/examples/RNOneSignal/
  3. git checkout reproduce-local-notif-conflict (branch with local notif repro code)
  4. yarn
  5. Build and run the example app by:
    • Open the RNOneSignal project in XCode
    • Change the Signing Team and Bundle Identifier for both the RNOneSignal target as well as the OneSignalNotificationServiceExtension
      • The Service Extension bundle id should be <main-target-bunde-id>.OneSignalNotificationServiceExtension

Your AppDelegate.m should look like this after following the OneSignal (remote notifications) setup instructions and the PushNotificationIOS (local notifications) setup instructions.

One thing to note is that it seems like the PushNotificationIOS docs have conflicting instructions…which brings me to the first issue:

Part 1: The code in those docs says to add this to your AppDelegate.m:

 // Required for the localNotification event.
 - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
 {
  [RCTPushNotificationManager didReceiveLocalNotification:notification];
 }

However, it also says to add

// Define UNUserNotificationCenter
  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;

which in theory should break the former. It would be nice to clarify this discrepancy.

Part 2: After adding the OneSignal SDK (remote notifications), the event listener for localNotification no longer is triggered.

In the OneSignal example app you built in the reproduction steps, tap “Send Local Notifs”. You will see in the console that the console.log in the localNotification handler is never fired after tapping on the local notification.

This may be an issue on our side (OneSignal). However, it isn’t clear to us why this is happening and the documentation isn’t clear on how to properly handle both the old (deprecated) and new ways of handling local notifications.

A better local notification click handler would use userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler so we would love to see this used in a future RN version (Apple docs). This would be the only way to solve the compatibility issue between plugins for the click handler for iOS 10+ devices.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Simekcommented, Sep 18, 2020

@safaiyeh React Native didReceiveLocalNotification method is still present in the code, can we remove it from the library first before removing it from the docs? 🙂

Also it looks like that RNTester is also using that handler (I’m not sure if there is a test related to that):


The @react-native-community/push-notification-ios team fixed the local notification issue for new iOS releases in this PR (hope this will shed some more light into the problem):

1reaction
carloscuestacommented, Sep 17, 2020

The docs for the AppDelegate.m part are confusing, as @rgomezp says didReceiveLocalNotification method should not be referenced anymore in the docs since its deprecated and should be be replaced by this, right ?

Screenshot 2020-09-17 at 13 09 41

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Local Notification - OnNotification not firing when ...
We tried React-native-Push-Notification, PushNotificationIOS library etc but all behaves the same. Any help will be highly appreciated. ios ...
Read more >
PushNotificationIOS - React Native
Valid events are: notification : Fired when a remote notification is received. The handler will be invoked with an instance of ...
Read more >
Notifications Not Shown - Mobile Push
These push servers then distribute the notifications to your subscribers. The "Confirmed" stat means our SDK received the notification which should have been ......
Read more >
Step by Step guide for Implementing Push Notifications in iOS ...
Prerequisite: 1. At least some hands-on experience working on react native, xcode, and handling the certificates on the apple developer account.
Read more >
iOS | Localytics Documentation - Upland Software
Starting in SDK v5.0, the Localytics SDK also will attempt to upload any datapoints ... remote notifications" in Step 4 (for auto and...
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