0

I have been trying to make an app with PARSE but I can't run it because I keep getting an error saying :

"Cannot invoke 'suscribeToChanelInBackground' with an argument list of type '(String, (Bool , NSError?)) -> ())''"

And it is pointing to the line of code:

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

Which is in the Push Notifications Section:

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)
    }
}

So I can't figure out what to do, I have been looking all over the web about it and I think it might be something to be to do with the new swift update Swift 2.0 (which I am using along with Xcode 7 beta) Is it my code , or parse's to do with the new swift? I have tried commenting it out because I don't need notifications in my app though apparently you need that section of code, and I might have to use the same code somewhere else which I think you do. Thank you in advance.

Lucas Smith
  • 698
  • 2
  • 9
  • 17

1 Answers1

0

Ok, I have the answer, if you have this problem, the template you are given is for swift 1 and for Xcode 6, so I did find out that someone did edit the code to make it suitable for swift 2 , so if you have any problems with them template, just download it here:

Parse New Template

Note: This is not made by parse or by me and so far I have not had any problem with this so , sorry if this does not work for you, because I am using Xcode 7 beta 6 not 7

Lucas Smith
  • 698
  • 2
  • 9
  • 17