iOS PUSH通知types选项? 警戒VS横幅?
我已经阅读了这里的post,build议将PUSH通知显示为警报而不是横幅的唯一方法是让单个最终用户在应用的Settings
的Settings
Notifications
部分更改Alert Style
。 令我感到困惑的是,有些应用程序默认使用Alerts
风格,而无需执行此操作。
有没有办法在首次启动时通过对话框以编程方式设置Alerts
样式? 我不介意要求用户在对话框中确认。 我只是知道,因为其他应用程序不需要用户手动进入设置来更改提醒样式,必须有一个不同的方法做这个…
我有以下 –
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)]; return YES; }
您的应用程序只具有检查通知设置的权限,您不能设置或更改用户的通知types。
查询通知types时,选项如下
typedef NS_OPTIONS(NSUInteger, UIRemoteNotificationType) { UIRemoteNotificationTypeNone = 0, UIRemoteNotificationTypeBadge = 1 << 0, UIRemoteNotificationTypeSound = 1 << 1, UIRemoteNotificationTypeAlert = 1 << 2, UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3, }
你可以从查询推送设置中find更多信息,而不是用户是否启用了警报,但没有显示它们是如何显示的(横幅与警报)。
不,这是不可能的,你不能这样做。
您可以使用此行查询通知样式的当前设置:
UIRemoteNotificationType* enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
您可以检查enabledTypes,然后指示用户更改设置中的通知样式。