简体   繁体   中英

Handling Parse Push Notifications in Android

I am using Parse API in order to handle push notifications. In our Android application, I want to accomplish two things:

1) If we have received a Push Notification with the application is closed and the user clicks on the notification, I want to be able to understand that the application is being opened via a push notification.

2)If we receive a push notification while the application is open, I want to handle this and do some extra work.

In both cases, I want to be aware that the application has received a push notification in order to execute some special operations.

As far as I understand from Parse API documentations, it offers two methods of handling pushes: Responding with an Activity and Responding with an Intent. I am currently calling

PushService.setDefaultPushCallback(context, MainActivity.class);

in my Application class with needed changes in the AndroidManifest.xml file and already receive push notifications, this corresponds to Responding with an Activity method. But I don't know how to be aware of Push Notifications explicity with this method.

Thanks in advance.

When a push is received ,Check

1:Whether our application is in foreground or background.

If it is foreground, that means app is visible and do your stuff(show alerts or anything you want).

If app is in background,that means it is not visible and if you want to do any thing based on this.

i hope this helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM