Open malwatte opened 7 years ago
@malwatte if there is an iOS system dialog on top of your app then the OS reports your app as being in the background. It's a quirk of iOS and there isn't anything I can do about it. You can also reproduce it by pulling down the notification shade.
@macdonst In my application,
Do you know a way to distinguish app is opened by a notification tap vs system dialog dismiss? Or is there a way we can put the notification on the shade if the app is blocked by a system dialog?
As per your comment if there is an iOS system dialog on top of your app then the OS reports your app as being in the background. But if the app is in background why the push is not shown in system notification shade? Is it the expected behaviour?
Thank you. Greatly appreciate your help.
I found that we would be able to identify if app is blocked by an iOS dialog (or notification header) using both UIApplicationStateBackground and UIApplicationStateActive.
if (application.applicationState != UIApplicationStateActive && application.applicationState != UIApplicationStateBackground) {
NSLog(@"Foreground Inactive");
}
Would it be possible to pass additional parameter to "notification" event handler to indicate above state (Foreground Inactive)?
@malwatte that is really good info. Thanks for digging into that. I'll have to put some thought in how to indicate that in the notification event. Right now we are using foreground
which is a boolean so it doesn't really give you the option of a third state.
See #851
@macdonst I am glad if above info would help to improve the plugin. I am not good at Objective C. But I can try to go through the code and try to come up with a solution too. Thank you.
@macdonst Any chance you were able to look into this? :)
@macdonst , I was wrong about the above if() condition. I have 0 knowledge in Objective C. Sorry. Actually application.applicationState is an enum. https://developer.apple.com/reference/uikit/uiapplicationstate
I believe we can do this in didReceiveRemoteNotification
if(application.applicationState == UIApplicationStateActive){
// App is in foreground and active
}
else if(application.applicationState == UIApplicationStateInactive){
// Show the notification in the shade OR save it to use in pushPluginOnApplicationDidBecomeActive
}
else {
// App is in background
}
Thoughts?
I am facing the same issue, when app is foreground notification handler calls automatically. Do you know how to stop it or check if the app is currently running or in background?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I came across an issue while I was testing in iOS 10.
If the app is in background (by pressing home button) the notifications are shown in notification bar. When I clicked the notification, app is opened and "notification" event is fired. additionalData.foreground value is false.
Problem is I want to differentiate these two scenarios separately. How do I identify if the app is opened by clicking a notification in notification bar OR blocked by an OS alert? Because in both the cases additionalData.foreground is false.
Device- iPad mini (OS v 10.0.1) Plugin version- 1.8.2 xcode version- 7.1
payload:
Thank you.
(sorry for bad english)