Worklight: error Push Notification on Android -



Worklight: error Push Notification on Android -

please help me! i've tried week prepare force notification demo still doesn't work! device not recieve messages after quit application.

this android element application-descriptor.xml file (with browser key):

<android version="1.0" securitytest="mobile-securitytest"> <worklightsettings include="false"/> <pushsender key="aizasybmdtjw8iqaa1mmtf9mksquqxyxofbkktk" senderid="430560385547"/> <security> <encryptwebresources enabled="false"/> <testwebresourceschecksum enabled="false" ignorefileextensions="png, jpg, jpeg, gif, mp4, mp3"/> <publicsigningkey>pushnotificationmyappandroid</publicsigningkey> <packagename>com.myapp</packagename> </security> <compresswebresources enabled="true"/> </android>

this main.js file:

$('#issupportbtn').bind("click", issupport); $('#issubscibedbtn').bind("click",issubscribed); $('#subscribebtn').bind("click",dosubscribe); $('#unsubscribebtn').bind("click",dounsubscribe); function issupport(){ var issupport = false; if(wl.client.push){ issupport = wl.client.push.ispushsupported(); } alert(issupport); } function issubscribed(){ var issubscribed = false; if(wl.client.push){ issubscribed = wl.client.push.issubscribed('mypush'); } alert(issubscribed); } if(wl.client.push){ wl.client.push.onreadytosubscribe = function(){ $('#subscribebtn').removeattr('disabled'); $('#unsubscribebtn').removeattr('disabled'); wl.client.push.registereventsourcecallback( "mypush", "adapterauth", "pusheventsource", pushnotificationreceived ); }; } function dosubscribe(){ wl.client.push.subscribe("mypush",{ onsuccess:function(){ alert("success"); }, onfailure:function(){ alert("fail"); } }); } function dounsubscribe(){ wl.client.push.unsubscribe("mypush",{ onsuccess:function(){ alert("success"); }, onfailure:function(){ alert("fail"); } }); } function pushnotificationreceived(props, payloads){ alert("pushnotificationreceived invoked"); alert("props :: " + json.stringify(props)); alert("payload :: " + json.stringify(payload)); }

this adapterauth-impl.js file:

function getuser() { homecoming {data:[{username:'hcv',password:"123456",bagde:'3',message:'hi, jane'},{username:'vi',password:'123',bagde:'3',message:'hi, luffy'}]}; } function onauthrequired(headers,errormessage){ errormessage = errormessage ? errormessage:null; return{ authrequired:true, errormessage:errormessage }; } function submitauth(username,password) { var response = {data:[{username:'hcv',password:"123456",bagde:'3',message:'hi, jane'},{username:'vi',password:'123',bagde:'3',message:'hi, luffy'}]}; (var i=0;i<response.data.length;i++){ if(username === response.data[i].username && password === response.data[i].password){ var identity={ userid: username, displayname: username, attributes:{foo:"bar"} }; wl.server.setactiveuser("authloginrealm", identity); return{ authrequired: false }; } } homecoming onauthrequired(null,"invalid login credentials"); } function onlogout(){ wl.server.setactiveuser("authloginrealm", null); wl.logger.debug("logged out"); } wl.server.createeventsource({ name:"pusheventsource", poll:{ interval:60, onpoll:"submitnotifications" }, securitytest:"mobile-securitytest", }); function submitnotifications() { var response = {data:[{username:'hcv',password:"123456",bagde:"3",message:"hi,jane"},{username:"vi",password:"123",bagde:"1",message:"hi, luffy"}]}; var messages = response.data; for(var i=0; < messages.length;i++){ var userid = wl.server.getactiveuser("authloginrealm"); if(messages[i].username === userid){ var usersubscription = wl.server.getusernotificationsubscription("adapterauth.pusheventsource", messages[i].username); if(usersubscription === null){ homecoming {result:"no user found:"+messages[i].username}; } var notification = wl.server.createdefaultnotification(messages[i].message, messages[i].bagde,{foo:'bar'}); wl.logger.debug("submitnotification >> userid :: " + messages[i].username + ", text :: " + messages[i].message); wl.server.notifyalldevices(usersubscription, notification); wl.logger.error("userid"+messages[i].username+"not found"); } } }

this error:

06-24 09:27:11.927: e/activitythread(3096): activity com.myapp.myapp has leaked intentreceiver com.google.android.gcm.gcmbroadcastreceiver@41c85190 registered here. missing phone call unregisterreceiver()? 06-24 09:27:11.927: e/activitythread(3096): android.app.intentreceiverleaked: activity com.myapp.myapp has leaked intentreceiver com.google.android.gcm.gcmbroadcastreceiver@41c85190 registered here. missing phone call unregisterreceiver()? 06-24 09:27:11.927: e/activitythread(3096): @ android.app.loadedapk$receiverdispatcher.<init>(loadedapk.java:763) 06-24 09:27:11.927: e/activitythread(3096): @ android.app.loadedapk.getreceiverdispatcher(loadedapk.java:567) 06-24 09:27:11.927: e/activitythread(3096): @ android.app.contextimpl.registerreceiverinternal(contextimpl.java:1055) 06-24 09:27:11.927: e/activitythread(3096): @ android.app.contextimpl.registerreceiver(contextimpl.java:1042) 06-24 09:27:11.927: e/activitythread(3096): @ android.content.contextwrapper.registerreceiver(contextwrapper.java:348) 06-24 09:27:11.927: e/activitythread(3096): @ com.google.android.gcm.gcmregistrar.setretrybroadcastreceiver(gcmregistrar.java:293) 06-24 09:27:11.927: e/activitythread(3096): @ com.google.android.gcm.gcmregistrar.register(gcmregistrar.java:215) 06-24 09:27:11.927: e/activitythread(3096): @ com.worklight.androidgap.plugin.push.subscribe(push.java:331) 06-24 09:27:11.927: e/activitythread(3096): @ com.worklight.androidgap.plugin.push.access$400(push.java:45) 06-24 09:27:11.927: e/activitythread(3096): @ com.worklight.androidgap.plugin.push$2.run(push.java:233) 06-24 09:27:11.927: e/activitythread(3096): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1076) 06-24 09:27:11.927: e/activitythread(3096): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:569) 06-24 09:27:11.927: e/activitythread(3096): @ java.lang.thread.run(thread.java:856)

i have tested application. managed receive force notification in 3 scenarios: when app in foreground, when app in background , when app close.

i have 2 comments:

var response = {data:[{username:'hcv',password:"123456",bagde:"3",message:"hi,jane"},{username:"vi",password:"123",bagde:"1",message:"hi,julian"}]};

here, badge should not in double-quotes. remove quotes.

the submitnotifications function... see building within of - notification text , user sent to, not how supposed be(!).

this function supposed receive these: submitnotifications(userid, notifivcationtext)

so don't know how sending force notifications, looks wrong me. anyway, work had change

if( messages[i].username === userid){ ...

to:

if( true || messages[i].username === userid){ ...

suggest re-read force notifications training module.

push-notification worklight worklight-adapters

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -