Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to differentiate bringing the app to the foreground via a notification tap #39

Open
pakoArtal opened this issue May 27, 2016 · 5 comments

Comments

@pakoArtal
Copy link

Hi,
This is be related to the issue App open from PushNotification click without payload where @cjadhav and @DFoxinator ask about getting the payload on clicking on notification.

To differentiate bringing the app to the foreground via a notification tap from just bringing the app to the foreground normally, I have tried the following:

  • At GCMIntentService.java add an Extra to the launcherIntent :
launcherIntent.putExtra("PUSH_LAUNCH", true);`
  • Somewhere in my code add an 'newIntent' event listener.
    I have tried with no luck:
win.activity.addEventListener("newIntent", function(e) {
     console.log('NEW INTENT ' + JSON.stringify(e.intent) + ' WITH EXTRA: ' + e.intent.getBooleanExtra('PUSH_LAUNCH', false));
});

and

Ti.Android.currentActivity.addEventListener('newintent', function(e) {
         console.log('NEW INTENT ' + JSON.stringify(e.intent) + ' WITH EXTRA: ' + e.intent.getBooleanExtra('PUSH_LAUNCH', false));
});

@FokkeZB opened a JIRA ticket :Android newintent event not fired so that could be reason I do not get it.

Do you know another way to do it?

@DFoxinator
Copy link

@pakoArtal were you ever able to figure this out?

@pakoArtal
Copy link
Author

Hi @DFoxinator,
No luck yet, if I get news I will write them here...
If I understand correctly we need a 'newIntent' listener. In the JIRA ticket related to the newIntent listener says:
Resolution: Unresolved
Affects Version/s: Release 5.2.0
Fix Version/s: Release 6.0.0

To get notified, Login to jira and press 'Start watching this issue' on https://jira.appcelerator.org/browse/TIMOB-4865

I heard that the more people watching the issue the fastest they solve it ....

@DFoxinator
Copy link

@pakoArtal thanks a bunch, what you're saying makes sense. The way you were trying to do it with newintent listener is what I was trying to do too.

I left a comment on the ticket asking about a workaround. This seems like very critical functionality, if in fact you literally can't properly open a Titanium app that's in the background from a push notification with a payload.

@bitfabrikken
Copy link

bitfabrikken commented Nov 1, 2016

You can do it yourself by using gcm.getLastData(); when you start the app

Edit: Actually, couldn't get this to work. Seems there is indeed a need for some way to detect if user clicked on the notification or not.

@mark22
Copy link

mark22 commented Feb 4, 2018

Agreed, this is critical functionality. Surprised this isn't included somehow??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants