Swift 2:推送通知设置

时间:2016-04-20 07:53:06

标签: swift push-notification ibm-cloud

我在推送通知代码表格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

}

它给我的错误是:"否' |'候选人产生预期的上下文结果类型' UIUserNotificationType'。清除它的第二个" |"那是错的。

我在Stackoverflow上找不到这个问题:

稍后在我的代码(Appdelegate)中,我在此代码中收到错误:

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

它说:"'应用程序的无效重新声明(_:didRecieiveRemoteNotification:fetchCompletionHander :)"

任何想法甚至意味着什么?

1 个答案:

答案 0 :(得分:1)

它是一个快速的数组

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