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] when foreground notification tapped `userInteraction` is still false

See original GitHub issue

Bug

[ios] when foreground notification tapped userInteraction is still false

Environment info

react-native info output:

info Fetching system and libraries information...
System:
    OS: Linux 4.15 elementary OS 5.1.5 Hera
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 2.68 GB / 15.58 GB
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 13.14.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 23, 26, 27, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.2
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 1.8.0_201 - /usr/bin/javac
    Python: 2.7.17 - /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 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 5.0.1

Steps To Reproduce

  1. Open your iOS app and keep it in foreground
  2. Send push, example apns payload:
{"data":{"address":"xxxx","txid":"xxxx","sat":636020,"type":2},"priority":"high","type":2,"level":"transactions","token": "xxxx","os":"ios","address":"xxxx","sat":1000031	,"txid":"xxxx"}
  1. Witness push notification overlay on top of your app. Tap it
  2. onNotification callback is fired, where payload is:
{"foreground":true,"userInteraction":false,...}

Describe what you expected to happen:

  1. userInteraction to be true

I can actually live with that, as Ive put this hack to handle it:

if (Platform.OS === 'ios' && notif.foreground === true && notif.userInteraction === false) wasTapped = true; // iOS hack

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
dsloungecommented, Aug 28, 2020

I just added react-native-push-notification to one of my apps, and I’ve had this same issue, where userInteraction doesn’t match if a user pressed the notification or not. I’m thinking that the bug might be on this repo. The field userInteraction doesn’t exist in the push-notification-ios repo. It’s value it’s determined here: https://github.com/zo0r/react-native-push-notification/search?q=userInteraction&unscoped_q=userInteraction

I might be able to help fix this issue, but I need more context. I stepped through the native code in push-notification-ios after receiving a remote push notification. When I tap on the notification, I noticed that push-notification-ios sends the localNotificationReceived: https://github.com/react-native-community/push-notification-ios/blob/947b300975f2de0069d95a70c6e305c2d7f5ae16/ios/RNCPushNotificationIOS.m#L230. Eventually that makes it to here in react-native-push-notification: https://github.com/zo0r/react-native-push-notification/blob/883d062716aacc55a4edd1c68078db6f206c91de/index.js#L353, where userInteraction is set to be isFromBackground, which doesn’t seem like the right thing. The only condition I’ve found to differentiate between receiving a push notification and opening one is that notification.message is null.

I’ve hunted through PR issues here and on the push-notifications-ios repo, and all the information I’ve found is a little cryptic, just pointing to the other repo 😅 . If this issue is already known, a clear description of it would help me or someone else fix it. 😄

0reactions
Dallas62commented, Sep 12, 2020

Hi! The version on dev branch fix this issue, can you test it ? Regards

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS push notification: how to detect if the user tapped on ...
I mean if the app is completely quitted, not in the background, yes didFinishLaunching will get called. But if you launch your app,...
Read more >
Push Notifications by Tutorials, Chapter 8: Handling Common ...
As of iOS 14, Apple now provides you the ability to decide whether or not you'd like the alert to display when the...
Read more >
Notifications | React Native Firebase
If an incoming message with this property exists, and the app is not currently visible (quit or in the background), a notification is...
Read more >
Push Notifications - Optimizely
The notification argument reliably contains a field called userInteraction which is true if the user has tapped on the notification and false otherwise....
Read more >
Notifications - System experiences - Human Interface Guidelines
Use an alert — not a notification — to display an error message. ... Handle notifications gracefully when your app is in the...
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