userInteraction always returns true on iOS
See original GitHub issueHi guys,
I’m facing an issue since few days that I don’t understand.
Here is the content of the notification I’m pushing via AWS SNS:
{
"APNS_SANDBOX":"{\"aps\":{\"alert\":{\"title\":\"My App\", \"body\":\"Body notif\",\"payload\":{\"type\":\"new_post\"}},\"sound\":\"default\", \"content-available\":\"1\"}}"
}
onNotification
is triggered when I receive the notification and a second time when I open the notification. Which is the expected behaviour.
foreground
is always false
, which is the expected behaviour when the app is on background or when I click on the notification. It’s true
when the app is on foreground.
The problem is when I want to check userInteraction
. The value is always true
wether I receive the notification or click on it.
I tried different scenario but userInteraction
is always true
.
Is it normal? Am I the only one having this behaviour? If someone has an idea on what I’m doing wrong, I would love to hear from him.
Thanks for your help.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:9
Top GitHub Comments
From this post I was able to trigger the method
onNotification
only when user taps on notification, by checking that the app state is inactive (which is not true when notification is received but not tapped). You just need to update yourAppDelegate.m
as follows:If you need to run jobs even when user does not tap the notification you might want to add a
didReceiveRemoteNotification
method with a third parameteruserTapped
(based on applicationState) inRCTPushNotificationManager.m
library. Then you would just have to branch it in the react native lib to fix what happens line 220 in https://github.com/zo0r/react-native-push-notification/blob/master/index.jsI have the same problem too. The problem lies on https://github.com/zo0r/react-native-push-notification/blob/master/index.js line 220
if the notification is received in background, the userInteraction will always be true