ios - Facebook Login integration into Parse.com App -
i trying implement facebook login option in app. followed instructions on parse website , on facebook developer page. added frameworks, modified plist file , added proper code when launch app exception:
2015-07-14 17:50:08.939 ########[35815:2144465] -[parsemanager coremanager]: unrecognized selector sent instance 0x7f9cdadad720 2015-07-14 17:50:08.953 ########[35815:2144465] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[parsemanager coremanager]: unrecognized selector sent instance 0x7f9cdadad720' *** first throw call stack: ( 0 corefoundation 0x000000010a3cdc65 __exceptionpreprocess + 165 1 libobjc.a.dylib 0x000000010a066bb7 objc_exception_throw + 45 2 corefoundation 0x000000010a3d50ad -[nsobject(nsobject) doesnotrecognizeselector:] + 205 3 corefoundation 0x000000010a32b13c ___forwarding___ + 988 4 corefoundation 0x000000010a32acd8 _cf_forwarding_prep_0 + 120 5 ######## 0x0000000105c822f0 +[pffacebookutils initializefacebookwithapplicationlaunchoptions:] + 151 6 ######## 0x0000000105954c6c -[smappdelegate application:didfinishlaunchingwithoptions:] + 1132 7 uikit 0x00000001088ef748 -[uiapplication _handledelegatecallbackswithoptions:issuspended:restorestate:] + 240 8 uikit 0x00000001088f0357 -[uiapplication _callinitializationdelegatesformainscene:transitioncontext:] + 2540 9 uikit 0x00000001088f319e -[uiapplication _runwithmainscene:transitioncontext:completion:] + 1349 10 uikit 0x00000001088f2095 -[uiapplication workspacedidendtransaction:] + 179 11 frontboardservices 0x000000010be2b5e5 __31-[fbsserialqueue performasync:]_block_invoke_2 + 21 12 corefoundation 0x000000010a30141c __cfrunloop_is_calling_out_to_a_block__ + 12 13 corefoundation 0x000000010a2f7165 __cfrunloopdoblocks + 341 14 corefoundation 0x000000010a2f6f25 __cfrunlooprun + 2389 15 corefoundation 0x000000010a2f6366 cfrunlooprunspecific + 470 16 uikit 0x00000001088f1b02 -[uiapplication _run] + 413 17 uikit 0x00000001088f48c0 uiapplicationmain + 1282 18 ######## 0x00000001059c4a9f main + 111 19 libdyld.dylib 0x000000010a918145 start + 1 ) libc++abi.dylib: terminating uncaught exception of type nsexception
these frameworks , libraries have on project:
the weird thing if create new project 0 have no problems @ , login works correctly.
edit: i'm still trying solve issue. managed launch app without errors changing pffacebookutils
initialization code from[pffacebookutils initializefacebookwithapplicationlaunchoptions:launchoptions];
[pffacebookutils initialize];
if try login through button code [pffacebookutils logininbackgroundwithreadpermissions:nil block:^(pfuser *user, nserror *error) {}
another exception appears terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'you must initialize pffacebookutils call +initializefacebookwithapplicationlaunchoptions'
i'm adding code i'm using suggested:
in appdelegate.m
#import <fbsdkcorekit/fbsdkcorekit.h> #import <parsefacebookutilsv4/pffacebookutils.h> - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions{ // parse [parse setapplicationid: smparseapplicationid clientkey: smparseclientid]; // facebook [pffacebookutils initializefacebookwithapplicationlaunchoptions:launchoptions]; [pfanalytics trackappopenedwithlaunchoptions:launchoptions]; //***** // google map api [gmsservices provideapikey: smgoolgemapapikey]; //***** return [[fbsdkapplicationdelegate sharedinstance] application:application didfinishlaunchingwithoptions:launchoptions]; } - (bool)application:(uiapplication *)application openurl:(nsurl *)url sourceapplication:(nsstring *)sourceapplication annotation:(id)annotation { return [[fbsdkapplicationdelegate sharedinstance] application:application openurl:url sourceapplication:sourceapplication annotation:annotation]; } - (void)applicationdidbecomeactive:(uiapplication *)application { [fbsdkappevents activateapp]; }
i've went through same struggle , tried many different ways go setting parse facebook login. have though, have no experience obj-c, here working swift parse w/ facebook login app hope can give insight.
in appdelegate.swift
:
func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject : anyobject]?) -> bool { parse.setapplicationid("id", clientkey:"key") pffacebookutils.initializefacebookwithapplicationlaunchoptions(launchoptions) fbsdkprofile.enableupdatesonaccesstokenchange(true) return fbsdkapplicationdelegate.sharedinstance().application(application, didfinishlaunchingwithoptions: launchoptions) } 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() }
in loginviewcontroller.swift
:
//my custom storyboard button @ibaction func fblogin(sender: anyobject) { var permissions = ["public_profile", "email"] pffacebookutils.logininbackgroundwithreadpermissions(permissions) { (user: pfuser?, error: nserror?) -> void in if let user = user { if user.isnew { println("user signed , logged in through facebook!") self.facebooksignup(user) } else { println("user logged in through facebook!") self.performseguewithidentifier("loginsuccessful", sender: self) } } else { println("uh oh. user cancelled facebook login.") } } } override func viewdidload() { super.viewdidload() if pfuser.currentuser() != nil { movetonextview() //segue next viewcontroller } } func facebooksignup(user: pfuser) -> void{ var request = fbsdkgraphrequest(graphpath: "me", parameters: nil) var userid:string request.startwithcompletionhandler { (connection: fbsdkgraphrequestconnection!, result: anyobject!, error: nserror!) -> void in if error == nil { user["fullname"] = result["name"] var facebookuserid = result["id"] as! string user["facebookuserid"] = facebookuserid user.save() self.performseguewithidentifier("loginsuccessful", sender: self) } else { println(error) pfuser.logout() } } }
Comments
Post a Comment