Handling Parse Push Notifications in Android

牧云@^-^@ 提交于 2019-12-13 02:37:56

问题


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.


回答1:


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..



来源:https://stackoverflow.com/questions/21624473/handling-parse-push-notifications-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!