Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Differentiate between background processing and selected notification #292

Closed
iggyfisk opened this issue Nov 2, 2015 · 5 comments
Closed
Labels

Comments

@iggyfisk
Copy link

iggyfisk commented Nov 2, 2015

I love the 1.4.0 update that triggers my 'notification' handler as soon as a notification with "content-available: 1" arrives in iOS, even when the app is paused. However, for these notifications I have no way of telling if the user tapped the notification or not. Here's the scenario:

When the server sends "You have a new message in your inbox!" with content-available set, I want the app to refresh the inbox. If, and only if, the user taps this notification, I want to navigate to the inbox. Currently for this notification and with the app paused my handler is called 1-2 times. First when the notification arrives, and then possibly a second time if the user taps the notification. Both times the handler is called with the exact same data, including "foreground: false".

There's even a third case, where the app is completely closed. Then my handler isn't called as soon as the notification arrives (I know this will be implemented eventually). Later on if the user taps the notification, the app cold starts and my handler gets called once, again with the exact same data.

Given these circumstances I can't figure out a way to determine if the user actually tapped on "You have a new message in your inbox!" so the app knows to navigate to the inbox. Is there another parameter that could be sent to the notification handler, alongside "foreground: true/false"?

@macdonst
Copy link
Member

macdonst commented Nov 2, 2015

@iggyfisk if you want to send a silent notification to iOS then you just omit the alert/title field in the notification but keep in the "content-available: 1" property. This way your on('notification') handler will be called with all your data but nothing will be put in the notification shade.

Make sense?

@iggyfisk
Copy link
Author

iggyfisk commented Nov 2, 2015

@macdonst Makes a lot of sense, I believe I'm one of the first (#80) to use your plugin that way 😄

But in this scenario I still want there to be an alert in the notification shade, so I'd have to send 2 notifications for each new message in the inbox; 1 invisible to trigger a server refresh, and 1 visible that the user can tap to navigate to the inbox. I think I'd rather hack something together with the device pause/resume events in that case, they'll give me a decent idea if my handler is triggered because of user interaction.

@macdonst
Copy link
Member

macdonst commented Nov 2, 2015

@iggyfisk well if you see data.additionalData.content-available is set to 1 when you run the on('notificaiton') event handler you can just assume it was already handled in the background.

@macdonst
Copy link
Member

macdonst commented Mar 9, 2016

Closing for inactivity

@macdonst macdonst closed this as completed Mar 9, 2016
@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants