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.

userInteraction always returns true on iOS

See original GitHub issue

Hi 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:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:9

github_iconTop GitHub Comments

8reactions
colaskirschoffcommented, Oct 11, 2018

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 your AppDelegate.m as follows:

image

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 parameter userTapped (based on applicationState) in RCTPushNotificationManager.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.js

1reaction
sckohcommented, Aug 7, 2017

I 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

On iOS, if a superview's userInteractionEnabled is NO, then all ...
But is it true that if the superview's userInteractionEnabled is set to NO, then all subviews and offspring is also disabled for user...
Read more >
Placing Objects and Handling 3D Interaction - Apple Developer
Place virtual content at tracked, real-world locations, and enable the user ... case: the update handler is always supposed to return at least...
Read more >
Disabling user interactivity with allowsHitTesting()
Now tapping the circle will always print “Rectangle tapped!”, because the circle will refuses to respond to taps.
Read more >
[Solved]-Comparison of unsigned expression >=0 is always true
Yes - since length returns an unsigned integer, it will always be 'greater than or equal to 0'. You can delete the status.length...
Read more >
Customize the iOS Instrumentation
Once you have instrumented your iOS application with the Mobile iOS SDK, ... true, When set to true , Ajax operations will always...
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