发布于 2017-07-03 09:44:02
所以,在AppStore上发布之后,它就开始工作了.
发布于 2017-06-29 14:09:17
注意到Xamarin指南顶部的大注释的要点,很多人有时会忽略它们。
注意:本节中的信息与iOS 9及更早版本有关,在这里保留它是为了支持较早的iOS版本。有关iOS 10及更高版本,请参阅“用户通知框架指南”,以支持iOS设备上的本地和远程通知。
如果能看到您自己的一些代码示例会很好,但它既不在这里也不在那里。
因此,正如您计划使用iOS 10设备一样,下面是我们使用的10.3 backwards.This代码中的代码,这些代码位于AppDelegate类中的FinishedLaunching()方法中。
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// iOS 10 or later
var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
{
if (granted)
{
InvokeOnMainThread(() => {
UIApplication.SharedApplication.RegisterForRemoteNotifications();
});
}
});
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.Current.Delegate = ADSelf;
}
else
{
// iOS 9 or before
var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
}关键是以下几行:
UIApplication.SharedApplication.RegisterForRemoteNotifications();或
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);发布于 2019-01-23 02:18:23
如果设备是模拟设备,则不能注册它。
https://stackoverflow.com/questions/44827285
复制相似问题