Swift 2:推送通知设置

Swift 2 : Push notification settings

我在使用可在此处找到的 Bluemix 推送通知代码表单时遇到了一些问题。

https://console.ng.bluemix.net/docs/services/mobilepush/t_enable_ios_notifications_register.html

********* 不知道我怎么错过了这个问题已经存在 *******

我写的错误代码是:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    let notificationTypes: UIUserNotificationType = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound
    let notificationSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    application.registerUserNotificationSettings(notificationSettings)
    application.registerForRemoteNotifications()

    return true

}

它给我的错误是:"No '|' candidates produce the expected contexual result type 'UIUserNotificationType'. To clear its the second "|" 这是错误的。


虽然我在 Whosebug 上没有找到这个问题:

稍后在我的代码(Appdelegate)中,我在这段代码中遇到错误:

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {

它说:"Invalid redeclartion of 'application(_:didRecieiveRemoteNotification:fetchCompletionHander:)"

知道这意味着什么吗?

它是 swift

中的一个数组

let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Sound, UIUserNotificationType.Alert, UIUserNotificationType.Badge]