pubnub pushnotification working in android but notification throw all subscribed channels -
am new in andriod , working in chat app using pubnub. required pushnotification format of pn_gcm.data. sending map<> data punub server. , testing gcm receiver http://apns-gcm.bryantan.info/ working fine getting notification web app server. when publish message pn_gcm punbub not getting notification gcm. thing wrong pls me subscribe notification:
//callbackmethod { final taskcompletionsource<boolean> task = new taskcompletionsource<>(); this.vinepub.pubnub.addpushnotificationsonchannels() .channels(channels) .deviceid(gcmregid) .async(new pncallback<pnpushaddchannelresult>() { @override public void onresponse(pnpushaddchannelresult result, pnstatus status) { // handle response if (!status.iserror()) { logger.info("channels registered push notifications" + channels); taks.setresult(boolean.true); } else { logger.info("failed registered channels push notifications" + channels); taks.setresult(boolean.false); } } }); } return task.gettask(); } ------------------------------------------------------------------------
// publish method
logger.info("sending message channel" + channel); // publish message , pushnotification channel map<string, object> messagepayload = new hashmap<>(); messagepayload.put("message", messageenvelope.getmessageenvelopestring()); map<string, object> datapayload = new hashmap<>(); datapayload.put("data", messagepayload); map<string, object> mobilepayload = new hashmap<>(); mobilepayload.put("pn_gcm", datapayload); mobilepayload.put("messages", message); mobilepayload.put("pn_debug", true); if (this.pubnub != null) { this.pubnub.publish() .message(mobilepayload) .channel(channel) .shouldstore(true) .usepost(true) .async(new pncallback<pnpublishresult>() { @override public void onresponse(pnpublishresult result, pnstatus status) { if (status.getstatuscode() == 200) { callback.onsuccess(true); } else { pnerrordata pnerrordata = status.geterrordata(); callback.onfailure(pnerrordata.getthrowable()); } } }); }
Comments
Post a Comment