google cloud messaging - GCM Cordova - Tap not opening app -


i'm using gcm cordova (downloaded yesterday cordova 2.6) find whilst i've got notifications received successfully, using example code. tapping on notification clears , closes notification list - doesn't launch app itself.

running app on phone connected eclipse shows me gcmintentservice receives message (onmessage) , runs 'releasing wakelock' app doesn't open. shouldn't it, or have change code example achieve this.

i've noticed if force stop app, notifications no longer received. normal?

it seems answer not simple - involves setting intent.

i followed article start: http://www.adobe.com/devnet/phonegap/articles/android-push-notifications-with-phonegap.html

the tap doesn't work @ point, did following. added following code manifest:

<intent-filter> <action android:name="nameofapp.startme" /> <category android:name="android.intent.category.default" /> </intent-filter> 

this code placed gcmintentservice.java file - replaces of notification code project above refers to:

    string message = extras.getstring("message");     string title = extras.getstring("title");      intent nintent = new intent("uk.ac.chester.uocmobile.startme");     nintent.addflags(intent.flag_activity_new_task);       nintent.addcategory(intent.category_default);     pendingintent pintent = pendingintent.getactivity(context, 0, nintent, 0);      notificationcompat.builder mbuilder =             new notificationcompat.builder(this)                 .setsmallicon(r.drawable.icon)                 .setcontenttitle(context.getstring(r.string.app_name))                 .setcontentintent(pintent)                 .setwhen(system.currenttimemillis())                 .setpriority(notification.priority_high)                 .setautocancel(true)                 .setcontenttext(message)                 .setdefaults(notification.default_all);     notificationmanager mnotificationmanager =         (notificationmanager) getsystemservice(context.notification_service);             mnotificationmanager.notify(0, mbuilder.build()); 

you'll need add import same file:

            import android.support.v4.app.notificationcompat; 

if without following process you'll error on compilation.

right click project, , go android tools -> add support library. add android support library, revision 13. adds calls project , makes work.

when tap on notification after this, open app - sending homepage you've set. may not ideal, works me. i've added onstart , onresume make sure app (in html/js) on either ios or android check new messages in same way facebook app works.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -