iOS PUSH 通知类型选项?警报与横幅? [英] iOS PUSH notification type options? Alert vs Banner?

查看:68
本文介绍了iOS PUSH 通知类型选项?警报与横幅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了此处的帖子,建议将 PUSH 通知显示为警报而不是横幅的唯一方法是让个人最终用户更改 中的 警报样式应用程序Settings 的通知 部分.让我感到困惑的是,有些应用默认为 Alerts 风格,而无需这样做.

I have read through posts on here suggesting that the only way to make PUSH notifications appear as an alert instead of a banner is for the individual end user to change the Alert Style in the Notifications section of the app's Settings. What puzzles me is that there are apps out there that default to Alerts style without having to do this.

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

Is there a way to programatically set Alerts style through a dialog upon initial launch? I don't mind asking the user to confirm in a dialog. I just know since other apps don't require the user to manually go into settings to change the alert style, there has to be a different method of doing this...

我有以下 -

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

推荐答案

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

Your app only has the rights to check for notification settings, you can never set or change notification types for a user.

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

When you query notification types the options are as follows

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

您可以通过查询推送设置来了解用户是否启用了警报,而不是它们的显示方式(横幅与警报).

All you can find out from querying the push settings is wether or not the user has enabled alerts but not how they are displayed (banner vs alert).

这篇关于iOS PUSH 通知类型选项?警报与横幅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆