Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

gcm.js doesn't launch my app's app.js

$
0
0

Hi,

I'm using gcm.js (http://iamyellow.net/post/40100981563/gcm-appcelerator-titanium-module) to handle notifications for my app on Android, with just the same code for gcm.js and gcm_activity.js as in the documentation. When the app is running, clicking a notification brings it up properly. However, when the app is killed, clicking a notification doesn't launch it properly : app.js is run, but all the global variables defined in it are not defined globally.

Any idea on how to work around this ? I considered detecting if global variables are missing with a try...catch and if so restart the app, but unfortunately restarting an app doesn't seem possible.

A bit of code: this is the intent used by gcm_activity.js to launch the app from the notification:

var mainActivityIntent = Ti.Android.createIntent({
            className: gcm.mainActivityClassName,
            packageName: Ti.App.id,
            flags : Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP
        }); 
        mainActivityIntent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
        activity.startActivity(mainActivityIntent);
Thanks

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>