【发布时间】:2015-04-28 09:12:18
【问题描述】:
所以我使用 PushSharp 将 c# 中的通知发送到我的 android 应用程序:
var push = new PushBroker();
push.RegisterGcmService(new GcmPushChannelSettings(androidKey) { });
push.QueueNotification(
new GcmNotification().ForDeviceRegistrationId(registrationId)
.WithJson("{\"alert\":\"" + PushMessageFormater.FormatMessage(ncRuleResult) + "\",\"badge\":7,\"sound\":\"sound.caf\"}"));
一切正常,通知已正确发送。
现在,我要做的就是从我的 MainActivity 检测当最终用户点击收到的通知时应用是否打开。
protected void onCreate(Bundle savedInstanceState) {
registrationGetter = new RegistrationGetter(this);
super.onCreate(savedInstanceState);
Intent intent = getIntent() ;
// How to check from here if the app is actually open further to a push tap.
}
我在 SO 中发现的只是我需要在 Intent 上放置一些额外的变量,但不幸的是,我找不到从 PushSharp 指定 Intent 的方法。
提前谢谢你。
【问题讨论】:
-
您的设备是否收到推送通知??
-
是的,我的设备正在接收推送通知。
-
您必须从后台服务/广播接收器检查应用程序是否在后台或正在运行。如果您在接收器中接收通知时调用活动会使您的应用程序进入前台..
-
ty @user1992200,但我的问题不是很清楚。我已经添加了那部分:“现在,我要做的就是从我的 MainActivity 中检测当最终用户点击收到的通知时应用程序是否打开。”
-
从主要活动中检查应用程序是否在前台是没有意义的..在点击通知时,您必须调用服务来检查应用程序是否是后台..
标签: android push-notification pushsharp