Search code examples
swift2ios9xcode7

[PFUserAuthenticationController registerAuthenticationProvider:]: unrecognized selector sent to instance 0x7f96c1fa6090


Getting this error in the logs:

2016-03-18 18:53:54.915 Tinder[715:229250] -[PFUserAuthenticationController registerAuthenticationProvider:]: unrecognized selector sent to instance 0x7f96c1fa6090
2016-03-18 18:53:54.919 Tinder[715:229250] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFUserAuthenticationController registerAuthenticationProvider:]: unrecognized selector sent to instance 0x7f96c1fa6090'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102e2ae65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104f0fdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000102e3348d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000102d8090a ___forwarding___ + 970
    4   CoreFoundation                      0x0000000102d804b8 _CF_forwarding_prep_0 + 120
    5   Tinder                              0x000000010249506a +[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:] + 225
    6   Tinder                              0x00000001023b3ccd _TFC6Tinder11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 541
    7   Tinder                              0x00000001023b4a53 _TToFC6Tinder11AppDelegate11applicationfS0_FTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVSs10DictionaryCSo8NSObjectPSs9AnyObject____Sb + 179
    8   UIKit                               0x00000001039e31f1 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
    9   UIKit                               0x00000001039e4397 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
    10  UIKit                               0x00000001039eacc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
    11  UIKit                               0x00000001039e7e7b -[UIApplication workspaceDidEndTransaction:] + 188
    12  FrontBoardServices                  0x000000010657e754 -[FBSSerialQueue _performNext] + 192
    13  FrontBoardServices                  0x000000010657eac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    14  CoreFoundation                      0x0000000102d56a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x0000000102d4c95c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x0000000102d4be13 __CFRunLoopRun + 867
    17  CoreFoundation                      0x0000000102d4b828 CFRunLoopRunSpecific + 488
    18  UIKit                               0x00000001039e77cd -[UIApplication _run] + 402
    19  UIKit                               0x00000001039ec610 UIApplicationMain + 171
    20  Tinder                              0x00000001023b57ad main + 109
    21  libdyld.dylib                       0x0000000105a5a92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Also getting an error in my code:

Thread 1: signal SIGABRT

but I don't yet have any outlets in my code.

My code in AppDelegate.swift (personal info replaced by "xxx"):

import UIKit
import Parse
import Bolts

// If you want to use any of the UI components, uncomment this line
// import ParseUI

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    //--------------------------------------
    // MARK: - UIApplicationDelegate
    //--------------------------------------

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Enable storing and querying data from Local Datastore.
        // Remove this line if you don't want to use Local Datastore features or want to use cachePolicy.
        Parse.enableLocalDatastore()

        let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
            ParseMutableClientConfiguration.applicationId = "xxx"
            ParseMutableClientConfiguration.clientKey = "xxx"
            ParseMutableClientConfiguration.server = "https://yourapp.herokuapp.com/parse"
        })

        Parse.initializeWithConfiguration(parseConfiguration)


        PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)

        PFUser.enableAutomaticUser()

        let defaultACL = PFACL();

        // If you would like all objects to be private by default, remove this line.
        defaultACL.publicReadAccess = true

        PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser:true)

        if application.applicationState != UIApplicationState.Background {
            // Track an app open here if we launch with a push, unless
            // "content_available" was used to trigger a background push (introduced in iOS 7).
            // In that case, we skip tracking here to avoid double counting the app-open.

            let preBackgroundPush = !application.respondsToSelector("backgroundRefreshStatus")
            let oldPushHandlerOnly = !self.respondsToSelector("application:didReceiveRemoteNotification:fetchCompletionHandler:")
            var noPushPayload = false;
            if let options = launchOptions {
                noPushPayload = options[UIApplicationLaunchOptionsRemoteNotificationKey] != nil;
            }
        if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) {
                PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
            }
    }
    if application.respondsToSelector("registerUserNotificationSettings:") {
            let userNotificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
        let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()
    } else {
            let types: UIRemoteNotificationType = [UIRemoteNotificationType.Badge, UIRemoteNotificationType.Alert, UIRemoteNotificationType.Sound]
        application.registerForRemoteNotificationTypes(types)
        }

        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }

    //--------------------------------------
    // MARK: Push Notifications
    //--------------------------------------

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

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

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

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

    func application(application: UIApplication,
        openURL url: NSURL,
        sourceApplication: String?,
        annotation: AnyObject) -> Bool {
            return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
    }

    func applicationDidBecomeActive(application: UIApplication) {
        FBSDKAppEvents.activateApp()
    }


}

Solution

  • I managed to fix this error doing the following:

    First I deployed the official version of Parse Server (instead of Rob's version). Open this link and click 'Deploy to Heroku', follow the steps. https://github.com/ParsePlatform/parse-server-example

    After that I downloaded the Parse Frameworks (including Facebook framework) from the link below and replaced all current frameworks in my project with these frameworks downloaded. https://parse.com/downloads/ios/parse-library/latest

    Other than that just follow the class steps (adding code to AppDelegate, Info.pslist e etc.

    Any problems, let me know.