简体   繁体   English

在Android中处理解析推送通知

[英]Handling Parse Push Notifications in Android

I am using Parse API in order to handle push notifications. 我正在使用Parse API来处理推送通知。 In our Android application, I want to accomplish two things: 在我们的Android应用程序中,我想完成两件事:

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. 1)如果我们收到关闭应用程序的推送通知,并且用户单击该通知,我希望能够了解该应用程序正在通过推送通知打开。

2)If we receive a push notification while the application is open, I want to handle this and do some extra work. 2)如果在应用程序打开时收到推送通知,我想处理此问题并做一些额外的工作。

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. 据我从Parse API文档中了解到,它提供了两种处理推送的方法:以活动响应和以意图响应。 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. 在我的Application类中,对AndroidManifest.xml文件进行了必要的更改,并且已经收到了推送通知,这相当于使用Activity方法进行响应。 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. 1:我们的应用程序是前台还是后台。

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.. 我希望这有帮助..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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