gpt4 book ai didi

ios - 'unsigned long ' UIUserNotificationSettings *' 的隐式转换不允许使用 arc

转载 作者:可可西里 更新时间:2023-11-01 03:38:09 25 4
gpt4 key购买 nike

iOS 8 中的推送通知不起作用。

错误显示:

implicit conversion of 'unsigned long 'UIUserNotificationSettings *' is disallowed with arc

代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[application registerUserNotificationSettings:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)];
return YES;
}

enter image description here我使用的是 ios 8.0 和 xcode 6 beta。

最佳答案

我从 below from official documentation of iOS 8. 得到

  • Apps that use local or push notifications must explicitly register the types of alerts that they display to users by using a UIUserNotificationSettings object. This registration process is separate from the process for registering remote notifications, and users must grant permission to deliver notifications through the requested options.
  • Local and push notifications can include custom actions as part of an alert. Custom actions appear as buttons in the alert. When tapped, your app is notified and asked to perform the corresponding action. Local notifications can also be triggered by interactions with Core Location regions.

还有阅读

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIUserNotificationSettings_class/index.html#//apple_ref/occ/cl/UIUserNotificationSettings

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/registerUserNotificationSettings :

所以答案应该是..

/// First register notification setting with settings type like 
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications]; // you can also set here for local notification.

关于ios - 'unsigned long ' UIUserNotificationSettings *' 的隐式转换不允许使用 arc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24006998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com