[ios] when foreground notification tapped `userInteraction` is still false
See original GitHub issueBug
[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
- Open your iOS app and keep it in foreground
- 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"}
- Witness push notification overlay on top of your app. Tap it
onNotification
callback is fired, where payload is:
{"foreground":true,"userInteraction":false,...}
Describe what you expected to happen:
userInteraction
to betrue
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:
- Created 3 years ago
- Reactions:3
- Comments:5
Top 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 >
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 Free
Top 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
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 fielduserInteraction
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=userInteractionI 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 thatpush-notification-ios
sends thelocalNotificationReceived
: https://github.com/react-native-community/push-notification-ios/blob/947b300975f2de0069d95a70c6e305c2d7f5ae16/ios/RNCPushNotificationIOS.m#L230. Eventually that makes it to here inreact-native-push-notification
: https://github.com/zo0r/react-native-push-notification/blob/883d062716aacc55a4edd1c68078db6f206c91de/index.js#L353, whereuserInteraction
is set to beisFromBackground
, 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 thatnotification.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. 😄Hi! The version on
dev
branch fix this issue, can you test it ? Regards