我正在尝试查找iOS设置中是否开启了通知的声音/振动。我正在使用Xamarin forms,但Xamarin.iOS也可以接受。
看起来像是这样的东西: UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Sound, new NSSet()); 但我不确定如何使用NSSet读取设置。
我正在尝试查找iOS设置中是否开启了通知的声音/振动。我正在使用Xamarin forms,但Xamarin.iOS也可以接受。
看起来像是这样的东西: UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Sound, new NSSet()); 但我不确定如何使用NSSet读取设置。
UserNotifications.framework
是在iOS 10中添加的,取代了 UIUserNotification
.
你可以使用 UNUserNotificationCenter
来确定开启了哪些功能:
var notificationSettings = await UNUserNotificationCenter.Current.GetNotificationSettingsAsync();
switch (notificationSettings.SoundSetting)
{
case UNNotificationSetting.Disabled:
break;
case UNNotificationSetting.Enabled:
break;
case UNNotificationSetting.NotSupported; // Simulator...
break;
}