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

app closed launch function?? #333

Closed
eros2187 opened this issue Nov 13, 2015 · 15 comments
Closed

app closed launch function?? #333

eros2187 opened this issue Nov 13, 2015 · 15 comments
Labels

Comments

@eros2187
Copy link

hello I wanted to know if it was possible to launch a function of timing and make it run even if the app is closed ?
there is a plugin as it does wotzapp that remains always open to speak!!
thank you

@nicoabie
Copy link

nicoabie commented Dec 4, 2015

To launch it where? If the app is closed you don't have access to the webview. Could you elaborate?

@EternallLight
Copy link

Hello,
I have probably a similar question.
Is it possible to launch the app if it is closed on receiving a notification? I tried the high with notifications with high priority - unfortunately, it does not help.

@nicoabie
Copy link

nicoabie commented Dec 9, 2015

If the app is not running (the plugin's webview is null) it caches the notification payload data see here
When the user taps on the notification that launches the app and when you register the notifications callback you are going to receive the cached payload. Is that not working for you?

@EternallLight
Copy link

Nicolás, thanks for your quick response.
Sure, it's working. However, in our case, we need to get the app running immediately without a notification (no 'title' or 'body' to specify in the payload) - say, for an incoming call, which is supposed to fire once the app gets loaded. I thought it's a default behaviour for all high priority notifications, but it seems that I was wrong.

@nicoabie
Copy link

nicoabie commented Dec 9, 2015

I think I see what you mean, but I don't know if that is possible check this link about content-available flag.
I'm not sure if you can put the app in foreground.
There is some work being done on android to emulate that behavior aswell this issue

@EternallLight
Copy link

From this changes, I see that the behaviour with "content-available: 1" is the same as now with no "title" and "body" keys. Unfortunately, it does not instantly launch the application if it is closed - the notification gets delivered to JavaScript only on the next app run.

@nicoabie
Copy link

Yes exactly, I don't know if it is possible to launch it without user interaction.

@EternallLight
Copy link

Well, Skype somehow does that unless force closed. Now I'm trying to figure out how.

@nicoabie
Copy link

True, keep us updated with your findings ;)

@EternallLight
Copy link

Works! :)
What I did is added a new parameter, "force_launch". If received a message with "force_launch": 1, it restarts the PushHandlerActivity, onCreate method of which restarts the MainActivity. This makes the app start if it was closed or move to foreground if it was hidden. I can push the changes if you need them.

@nicoabie
Copy link

Please do so @EternallLight, then some work will need to be done on the other platforms but it is a good start to begin with! Thanks.
@macdonst do you agree?

@EternallLight
Copy link

I've made a fork and committed my changes there. Not sure what branch I have to make a pull request for. Since it's done only for one platform, it might be a good idea to create a separate branch for this, wait until another platforms will be ready, and merge it to the next release branch.

@macdonst
Copy link
Member

@EternallLight please just submit a PR for it. Sometimes what is possible for one platform is not possible for another, no sense depriving folks of the new functionality.

@EternallLight
Copy link

@macdonst I've just submited a pull request, please check it out.

@macdonst macdonst added this to the Release 1.7.0 milestone Apr 11, 2016
@macdonst macdonst modified the milestones: Release 1.8.0, Release 1.7.0 Jun 6, 2016
hanicker added a commit to hanicker/phonegap-plugin-push that referenced this issue Jul 15, 2016
@macdonst macdonst modified the milestone: Release 1.8.0 Sep 9, 2016
@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 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

4 participants