相关疑难解决方法(0)

Swift 2.0 - 二进制运算符"|" 不能应用于两个UIUserNotificationType操作数

我试图以这种方式注册本地通知的应用程序:

UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil))
Run Code Online (Sandbox Code Playgroud)

在Xcode 7和Swift 2.0中 - 我收到错误Binary Operator "|" cannot be applied to two UIUserNotificationType operands.请帮我.

ios swift swift2

191
推荐指数
3
解决办法
5万
查看次数

使用适用于iOS 10的UNUserNotificationCenter

尝试使用Firebase注册远程通知,但是在实现以下代码时,我收到错误:

UNUserNotificationCenter仅适用于iOS 10.0或更高版本

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        var soundID: SystemSoundID = 0
        let soundFile: String = NSBundle.mainBundle().pathForResource("symphony", ofType: "wav")!
        let soundURL: NSURL = NSURL(fileURLWithPath: soundFile)
        AudioServicesCreateSystemSoundID(soundURL, &soundID)
        AudioServicesPlayAlertSound(soundID)
        Fabric.with([Twitter.self])


        //Firebase configuration
        FIRApp.configure()

        //Resource code from stackoverflow to create UNUserNotificationCenter
        let center = UNUserNotificationCenter.current()
        center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
            // Enable or disable features based on authorization.
        }
        application.registerForRemoteNotifications()
        return true
    }
Run Code Online (Sandbox Code Playgroud)

通过简单的"修复它"不能通过基于操作系统版本号创建if语句来解决我的问题.对于UserNotifications框架,我应该做什么或想到这个解决方案?

apple-push-notifications swift firebase-cloud-messaging

4
推荐指数
1
解决办法
3715
查看次数