检测通知中心设置

发布于 2024-12-10 05:58:31 字数 129 浏览 3 评论 0原文

我的应用程序需要在 iOS 5 通知中心设置为“警报”并打开“声音”。据我发现,您的应用程序不可能提供正确的设置,这将是最好的选择,所以如果我错了,请纠正我。

因此,我正在寻找一种程序来检测当前设置并警告用户如果这些设置不正确。

My app needs to be set in iOS 5 Notification Center as 'alerts' and with 'sounds' on. From what I have found it is not possible for your app to offer setting these correctly, which would be the best option so correct me if im wrong.

So, I am looking for a procedure to detect the current settings and warn the user if these are not correct.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

被翻牌 2024-12-17 05:58:31

实际上可以通过以下方法来完成 -

UIRemoteNotificationType 类型 =
[UIApplicationsharedApplication].enabledRemoteNotificationTypes;

而类型是

typedef enum 
{    
  UIRemoteNotificationTypeNone    = 0,   
  UIRemoteNotificationTypeBadge   = 1 << 0,   
  UIRemoteNotificationTypeSound   = 1 << 1,   
  UIRemoteNotificationTypeAlert   = 1 << 2,   
  UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3 
}

根据:
http://developer.apple.com/库/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html
因此,如果您想知道用户是否批准您的应用接收通知,您所需要做的就是检查是否 types >= 4
请注意:这不会告诉您用户是否为您的应用启用或禁用了通知中心,它只会告诉您用户批准的通知类型

actually it can be done with the following method -

UIRemoteNotificationType types =
[UIApplicationsharedApplication].enabledRemoteNotificationTypes;

while types is

typedef enum 
{    
  UIRemoteNotificationTypeNone    = 0,   
  UIRemoteNotificationTypeBadge   = 1 << 0,   
  UIRemoteNotificationTypeSound   = 1 << 1,   
  UIRemoteNotificationTypeAlert   = 1 << 2,   
  UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3 
}

according to:
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html
So if you want to know if the user approved your app for notifications, all you need to do is to check whether types >= 4
be aware: this will not tell you if the user has enabled or disabled notification center for your app, it will only tell you the TYPE of the notification that the user approved

握住我的手 2024-12-17 05:58:31

这不能以编程方式完成。 “registerForRemoteNotificationTypes”用于远程(推送)通知,而不是本地通知。

我唯一能做的就是在应用程序商店的应用程序描述中包含有关如何设置通知中心的说明。我也把它放在我的演示视频中。

您还可以考虑在应用程序首次启动时添加提示,解释应用程序的“正确”通知设置。不要在后续启动中显示它,而是在“帮助”部分中提供它。

当然,“正确的”是用户想要的,但对于我的应用程序,用户从来不想要默认设置,即“横幅”。我的应用程序的最佳用户体验只是“声音”。在通知中心之前,对我的应用程序最大的抱怨是本地通知的弹出窗口。现在,通过通知中心,用户可以关闭除“声音”之外的所有内容。这似乎是他们都想要的设置。为什么我作为开发人员不能将其作为默认值提供给他们?如果他们想将其更改为其他内容,那很好,但我应该控制默认设置。但我是在吐槽。

This cannot be done programmatically. And "registerForRemoteNotificationTypes" is for remote (push) notifications, not local ones.

The only thing I have been able to do is include in my app description on the app store an explanation on how to set up the Notification Center. I also put it in my demonstration video.

You may also think about putting in a prompt the first time the app is launched explaining the "correct" notification settings for your app. Don't show it on subsequent launches, but have it available in a "help" section.

Sure, "what is correct" is what the user wants, but for my app, the users have NEVER wanted the default settings, which is "banners". The best user experience for my app is "sounds" only. The biggest complaint about my app before Notification Center was the pop ups from the local notifications. Now, with Notification Center, users can turn off everything except for "sounds". That is the setting that they all seem to want. Why can't I as a developer just give it to them as the default? If they want to change it to something else, that's great, but I should have control over the default settings. But I'm ranting.

初心 2024-12-17 05:58:31

我不认为这可以通过编程来完成。

您可以规定您的应用程序在启动时可以接受哪些警报。

我会在应用程序委托 didFinishLaunchingWithOptions 方法中使用它

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:   (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; 

I don't think this can be done programmatically.

You can stipulate though what alerts your app can accept when launched.

I would use this in the app delegate, didFinishLaunchingWithOptions method

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:   (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; 
薄荷港 2024-12-17 05:58:31

可以这样想:作为用户,如果所有其他应用程序都将这些设置为打开,您会怎么想? (当然,您希望在您的应用程序中启用它。但并非所有应用程序都像您的应用程序一样好。)或者,如果其他应用程序每次启动时都会警告您?

不可能,这就是原因。

就像尼克说的那样,只需提供您希望用户启用的所有内容即可。然后系统将给用户一个允许这样做的机会。

Think of it this way: what would you, as a user, think if every other app set these on? (Sure, you want it on for your app. But not all apps are good like yours.) Or, if every other app warned you every time it launched?

Not possible, and that's why.

Like Nik said, just put up everything you hope the user will enable. The system will then give the user a chance to allow this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文