我读过这里的帖子,建议让推送通知显示为警报而不是横幅的唯一方法是单个最终用户更改Alert Style
in the Notifications
应用程序的部分Settings
。让我困惑的是,有些应用程序默认为Alerts
风格,而不必这样做。
有没有办法以编程方式设置Alerts
首次启动时通过对话框设置样式?我不介意要求用户在对话框中确认。我只知道由于其他应用程序不需要用户手动进入设置来更改警报样式,因此必须有不同的方法来执行此操作......
我有以下内容 -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
return YES;
}
您的应用程序仅有权检查通知设置,您永远无法设置或更改用户的通知类型。
查询通知类型时选项如下
typedef NS_OPTIONS(NSUInteger, UIRemoteNotificationType) {
UIRemoteNotificationTypeNone = 0,
UIRemoteNotificationTypeBadge = 1 << 0,
UIRemoteNotificationTypeSound = 1 << 1,
UIRemoteNotificationTypeAlert = 1 << 2,
UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
}
通过查询推送设置,您只能得知用户是否启用了警报,但无法得知警报的显示方式(横幅与警报)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)