Android - Can Not Receive Push From Parse.com
I have parse notifications set up for my android app using Parse 1.7.1 sdk version. But in the new android this method with parse says to call is depreciated. PushService.setDefaul
Solution 1:
Try extending ParsePushBroadcastReceiver class and and use its
- OnPushRecieve (to do something before notification is shown in status bar)
- OnPushOpen (to do some action when user open's push for example open an activity)
- getNotification and
- onPushDismiss methods And in manifest file replace
<receiverandroid:name="com.parse.ParsePushBroadcastReceiver"android:exported="false"><intent-filter><actionandroid:name="com.parse.push.intent.RECEIVE" /><actionandroid:name="com.parse.push.intent.DELETE" /><actionandroid:name="com.parse.push.intent.OPEN" /></intent-filter></receiver>
with this :
<receiverandroid:name="com.example.parse.Notifications.NotificationsReciever"android:exported="false" ><intent-filter><actionandroid:name="com.parse.push.intent.RECEIVE" /><actionandroid:name="com.parse.push.intent.DELETE" /><actionandroid:name="com.parse.push.intent.OPEN" /></intent-filter></receiver>
And if you want to open an activity onPushOpen, here is a sample:
@Override
protected voidonPushOpen(Context context, Intent intent) {
// TODO Auto-generated method stubIntent i = newIntent(context, PushNotificationHandler.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
Here is a sample class that extends ParsePushBroadcastReciever class
public classNotificationsRecieverextendsParsePushBroadcastReceiver {
@Override
protected Class<? extendsActivity> getActivity(Context arg0, Intent arg1) {
// TODO Auto-generated method stubreturnParseStarterProjectActivity.class;
}
@Override
protected NotificationgetNotification(Context context, Intent intent) {
// TODO Auto-generated method stubreturnsuper.getNotification(context, intent);
}
@Override
protected voidonPushDismiss(Context context, Intent intent) {
// TODO Auto-generated method stubsuper.onPushDismiss(context, intent);
}
@Override
protected voidonPushOpen(Context context, Intent intent) {
// TODO Auto-generated method stubIntent i = newIntent(context, PushNotificationHandler.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
@Override
protected voidonPushReceive(Context context, Intent intent) {
//here You can handle push before appearing into status e.g if you want to stop it.super.onPushReceive(context, intent);
}
}
Post a Comment for "Android - Can Not Receive Push From Parse.com"