iOS PUSH通知类型选项?警报与横幅?

时间:2013-10-04 16:08:15

标签: ios objective-c push

我已阅读此处的帖子,建议将PUSH通知显示为警告而不是横幅的唯一方法是让个别最终用户更改Alert Style部分中的Notifications该应用的Settings。令我困惑的是,有些应用程序默认为Alerts样式,而不必这样做。

有没有办法在首次启动时通过对话框以编程方式设置Alerts样式?我不介意要求用户在对话框中确认。我只是知道,因为其他应用程序不要求用户手动进入设置以更改警报样式,必须有不同的方法来执行此操作...

我有以下内容 -

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
    return YES;
}

2 个答案:

答案 0 :(得分:7)

您的应用只有权检查通知设置,您永远不能为用户设置或更改通知类型。

查询通知类型时,选项如下

typedef NS_OPTIONS(NSUInteger, UIRemoteNotificationType) {
    UIRemoteNotificationTypeNone    = 0,
    UIRemoteNotificationTypeBadge   = 1 << 0,
    UIRemoteNotificationTypeSound   = 1 << 1,
    UIRemoteNotificationTypeAlert   = 1 << 2,
    UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
}

您可以通过查询推送设置找到所有内容,但用户是否启用了警报,但未显示警报的显示方式(横幅与警报)。

答案 1 :(得分:1)

不,这是不可能的,你做不到。

您可以使用此行查询通知样式的当前设置:

UIRemoteNotificationType* enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

您可以检查enabledTypes,然后指示用户更改设置中的通知样式。

相关问题