parse.com - Detecting arrival of push notifications in android app -
parse.com - Detecting arrival of push notifications in android app -
is possible observe arrival of force notifications programmatically on android app? how should 1 proceed implement same?
as @drees suggested in comment, can create custom broadcastreceiver extends parsepushbroadcastreceiver.
like this:
public class parsecustombroadcastreceiver extends parsepushbroadcastreceiver { @override public void onreceive(context context, intent intent) { seek { // sample code jsonobject json = new jsonobject(intent.getextras().getstring("com.parse.data")); final string notificationtitle = json.getstring("title").tostring(); final string notificationcontent = json.getstring("alert").tostring(); final string uri = json.getstring("uri"); //create taskstack builder - sample(incomplete) give thought intent resultintent = null; taskstackbuilder stackbuilder = taskstackbuilder.create(context); // customize notification notificationcompat.builder builder = new notificationcompat.builder(context) .setsmallicon(r.mipmap.ic_notification_icon) .setcontenttitle(notificationtitle) .setcontenttext(notificationcontent) .setgroup(group_shortr_notifs) .setcontentintent(resultpendingintent) .setautocancel(true) .setvisibility(notification.visibility_public) .setdefaults(notification.default_vibrate) .setstyle(new notificationcompat.bigtextstyle() .bigtext(notificationcontent)); int mnotificationid = 001; notificationmanager mnotifymgr = (notificationmanager) context.getsystemservice(context.notification_service); mnotifymgr.notify(mnotificationid, builder.build()); } grab (jsonexception e) { log.d(tag, e.getmessage()); } } }
add next in manifest.
<receiver android:name=".receivers.parsecustombroadcastreceiver" android:exported="false" > <intent-filter> <action android:name="com.parse.push.intent.receive" /> <action android:name="com.parse.push.intent.delete" /> <action android:name="com.parse.push.intent.open" /> </intent-filter> </receiver>
if next this tutorial above manifest edit requires alter android:name property.
hope helps.
android parse.com push-notification
Comments
Post a Comment