0

我一直在尝试使用 PARSE 制作一个应用程序,但我无法运行它,因为我不断收到一条错误消息:

“不能使用类型为 '(String, (Bool, NSError?)) -> ())'' 的参数列表调用 'suscribeToChanelInBackground'”

它指向代码行:

PFPush.subscribeToChannelInBackground((succeeded: Bool, error: NSError?)){

这是在推送通知部分:

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    let installation = PFInstallation.currentInstallation()
    installation.setDeviceTokenFromData(deviceToken)
    installation.saveInBackground()

    PFPush.subscribeToChannelInBackground((succeeded: Bool, error: NSError?)){
        if succeeded {
            print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n");
        } else {
            print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
        }
    }
}

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    if error.code == 3010 {
        print("Push notifications are not supported in the iOS Simulator.\n")
    } else {
        print("application:didFailToRegisterForRemoteNotificationsWithError: %@\n", error)
    }
}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    PFPush.handlePush(userInfo)
    if application.applicationState == UIApplicationState.Inactive {
        PFAnalytics.trackAppOpenedWithRemoteNotificationPayload(userInfo)
    }
}

所以我不知道该怎么做,我一直在网上寻找它,我认为这可能与新的 swift update Swift 2.0(我与 Xcode 7 beta 一起使用)有关是我的代码,还是解析与新的 swift 相关?我已尝试将其注释掉,因为我的应用程序中不需要通知,尽管显然您需要该部分代码,并且我可能不得不在其他地方使用相同的代码,我认为您会这样做。先感谢您。

4

1 回答 1

0

好的,我有答案了,如果你有这个问题,给你的模板是 swift 1 和 Xcode 6,所以我确实发现有人编辑了代码以使其适合 swift 2,所以如果你有他们的模板有任何问题,只需在此处下载:

解析新模板

注意:这不是由 parse 或我制作的,到目前为止我对此没有任何问题,如果这对您不起作用,抱歉,因为我使用的是 Xcode 7 beta 6 而不是 7

于 2015-10-05T11:44:14.133 回答