使用Xamarin Forms开发移动应用程序。对于推送通知,我们使用Amazon Simple Notification Service(SNS)。
Xamarin.Andriod: 1. 在安装应用程序时,我们在MainActivity的OnCreate方法中使用以下代码片段将设备ID注册到Amazon SNS中。它能正常工作。
using (Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER"))
{
string senders = AmazonUtils.GoogleConsoleProjectId;
intent.SetPackage("com.google.android.gsf");
intent.PutExtra("app", PendingIntent.GetBroadcast(this, 0, new Intent(), 0));
intent.PutExtra("sender", senders);
this.StartService(intent);
}
- 每次应用程序打开时,都要检查相应的设备 ID 是否已在 Amazon SNS 中注册。由于这个过程需要额外的 4 秒来检查,因此页面加载较慢。
- 我们需要每次打开应用程序时都检查设备是否已注册吗?这是推送通知的标准吗?
谢谢, Cheran