gpt4 book ai didi

Xamarin iOS : Check if notification sound is enabled

转载 作者:行者123 更新时间:2023-12-03 00:35:14 26 4
gpt4 key购买 nike

我正在尝试查明用户是否在 iOS 设置中打开了通知声音/振动。我正在使用 Xamarin 表单,但 Xamarin.iOS 也可以接受。

看起来就像是这样UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Sound, new NSSet());但我不确定如何使用 NSSet 来读取设置。

最佳答案

iOS 10 中添加了 UserNotifications.framework 并替换了 UIUserNotification

您可以使用UNUserNotificationCenter来确定启用的内容:

var notificationSettings = await UNUserNotificationCenter.Current.GetNotificationSettingsAsync();
switch (notificationSettings.SoundSetting)
{
case UNNotificationSetting.Disabled:
break;
case UNNotificationSetting.Enabled:
break;
case UNNotificationSetting.NotSupported; // Simulator...
break;
}

关于Xamarin iOS : Check if notification sound is enabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45944154/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com