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

use*_*643 6 push objective-c ios

我经历的帖子就在这里暗示,为了使推送通知的唯一途径出现一个警告而不是横幅广告是个人终端用户改变读取Alert StyleNotifications应用程序的部分Settings.令我困惑的是,有些应用程序默认为Alerts样式而不必这样做.

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

我有以下 -

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

Jas*_*lli 7

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

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

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

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