【发布时间】:2017-02-27 07:07:30
【问题描述】:
您好,我正在使用Push Notification Plugin for Xamarin 在我的应用程序中实现推送通知,并且我正在接收推送通知(使用 GCM),但问题是我发送到设备的推送通知在我发送新通知时被替换,并且不是预期的行为,我想显示收到的所有通知,这就是我配置我的 android 应用程序的方式
public override void OnCreate()
{
base.OnCreate();
AppContext = this.ApplicationContext;
CrossPushNotification.NotificationContentTextKey = "message";
CrossPushNotification.NotificationContentTitleKey = "contentTitle";
CrossPushNotification.NotificationContentDataKey = "data";
CrossPushNotification.Initialize<CrossPushNotificationListener>("MYANDROIDSENDERID");
//This service will keep your app receiving push even when closed.
CrossPushNotification.Current.Register();
StartPushService();
RegisterActivityLifecycleCallbacks(this);
}
public static void StartPushService()
{
AppContext.StartService(new Intent(AppContext, typeof(PushNotificationService)));
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat)
{
Random rnd = new Random();
// Publish the notification:
PendingIntent pintent = PendingIntent.GetService(AppContext,0, new Intent(AppContext, typeof(PushNotificationService)),0);
AlarmManager alarm = (AlarmManager)AppContext.GetSystemService(Context.AlarmService);
alarm.Cancel(pintent);
}
}
我错过了什么?
【问题讨论】:
-
您收到一个推送通知然后发送第二个,或者您同时发送两个到 GCM?还请告诉我,您是否打开了第一个通知?您希望从以前的通知中保留哪些内容?
-
我收到一个推送通知,但我什么也没做,然后我在一段时间后发送第二个,而不是显示两个通知我只能看到最后一个发送到设备的通知..跨度>
标签: c# xamarin xamarin.forms