[ios] when foreground notification tapped `userInteraction` is still false
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
- 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
onNotificationcallback is fired, where payload is:
{"foreground":true,"userInteraction":false,...}
Describe what you expected to happen:
userInteractionto 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
Hi @Overtorment Yes, it's a known issue but there is actually no way to get the real value. Need to implement this directly in the iOS repository.
Even your change doesn't work for remote notifications without user interaction.
Is there a ticket in ios repo or should I create one?
There is two issue and the recent one is :
https://github.com/react-native-community/push-notification-ios/issues/152
But I think a PR would be more appreciated. I need to find time for this one and another one where values are all null.
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. 😄
Hi!
The version on dev branch fix this issue, can you test it ?
Regards