m4t*_*mus 4 xamarin.ios xamarin xamarin.forms
我试图找出用户是否在iOS设置中启用了声音/振动通知功能。我正在使用Xamarin表单,但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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
463 次 |
| 最近记录: |