我已经阅读了这里的帖子,建议让 PUSH 通知显示为警报而不是横幅的唯一方法是让个人最终用户更改 中的
部分。让我感到困惑的是,有些应用程序可以默认为 Alert Style
应用程序 设置
的通知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,
}
通过查询推送设置,您只能知道用户是否启用了警报,但不知道警报的显示方式(横幅与警报)。
关于iOS PUSH 通知类型选项?警报与横幅?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19185886/