关于Android的推送通知查询 [英] Query regarding Android push notifications
问题描述
我有成立一个工作推送通知的Android应用程序。它的工作原理目前是这样的:
I have an Android app with a working push notification set up. It works currently like this:
- 用户得到一个推送通知
- 当用户点击了推送通知,他被带到里面有所有的通知列表的屏幕。它基本上是有所有通知的列表视图。
现在,要实现以下内容:
Now, want to implement the following:
一个。当一个新的通知来给用户,其对列表视图被显示,而不管用户是否点击了它
a. When a new notification comes to the user, it has to be displayed on the list view, irrespective of whether a user taps on it.
乙。我必须表明该用户已在应用程序图标收到的通知的数量。例如,如果你在什么应用得到一个消息,它显示的信息的应用程序图标的数量。
b. I have to indicate the number of notifications that user has received on the app icon. For instance, if you get a message in whats app, it displays the number of messages on the app icon.
任何人可以让我知道什么是实现这些功能的最好的方式?如果有人能指出我的教程/引用,那将是非常有益的。
Could anybody let me know what is the best possible way to implement these functionality? If anybody could point me to tutorials/references, it would be very helpful.
谢谢!
推荐答案
一。从接收器(GCM / C2DM接收器)当推通知到达
a. Launch an activity from the receiver(GCM/C2DM receiver) when the push notification arrives
// Your C2DM receiver (for GCM check the Android Documentation)
public void onReceive(final Context context, final Intent intent)
{
if (intent.getAction().equals(com.google.android.c2dm.intent.RECEIVE))
{
//start your list view activity of notifications
Intent i = new Intent();
i.setClassName("com.test", "com.test.NotificationsActivity");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
乙。检查<一href=\"http://stackoverflow.com/questions/17565307/how-to-display-count-of-notifications-in-app-launcher-icon\">this.
这篇关于关于Android的推送通知查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!