My app works fine and is able to login with the Facebook SDK and obtain access code.
However when I try to create a backendless user with the below code I get the below error. This code sits in the successful Facebook login button delegate function and works fine if this snippet is removed.
CODE:
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
let fieldsMapping = [
"email": "email",
"id" : "facebookId",
"birthday": "birthday",
"first_name": "firstName",
"last_name" : "lastName",
"gender": "gender"
]
backendless.userService.setStayLoggedIn(true)
let token = FBSDKAccessToken.currentAccessToken()
backendless.userService.loginWithFacebookSDK(
token,
fieldsMapping: fieldsMapping,
response: { (user: BackendlessUser!) -> Void in
print("user: \(user)")
},
error: { (fault: Fault!) -> Void in
print("Server reported an error: \(fault)")
})
}
Error:
2016-03-08 19:21:08.643 APP_NAME[3241:522682] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]’
*** First throw call stack:
(
0 CoreFoundation 0x01d52a14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x048cee02 objc_exception_throw + 50
2 CoreFoundation 0x01bf7d64 -[__NSPlaceholderArray initWithObjects:count:] + 340
3 CoreFoundation 0x01c5bae4 +[NSArray arrayWithObjects:count:] + 68
4 Snapshot Deals 0x00428dca -[UserService loginWithFacebookSocialUserId:accessToken:expirationDate:permissions:fieldsMapping:responder:] + 234
5 Snapshot Deals 0x004278be -[UserService loginWithFacebookSDK:fieldsMapping:responder:] + 181
6 Snapshot Deals 0x00427fc4 -[UserService loginWithFacebookSDK:fieldsMapping:response:error:] + 92
7 Snapshot Deals 0x0010929c TFC14Snapshot_Deals14ViewController11loginButtonfS0_FTGSQCSo16FBSDKLoginButton_21didCompleteWithResultGSQCSo28FBSDKLoginManagerLoginResult_5errorGSQCSo7NSError__T + 3244
8 Snapshot Deals 0x00109c2c TToFC14Snapshot_Deals14ViewController11loginButtonfS0_FTGSQCSo16FBSDKLoginButton_21didCompleteWithResultGSQCSo28FBSDKLoginManagerLoginResult_5errorGSQCSo7NSError__T + 108
9 FBSDKLoginKit 0x0268019d __35-[FBSDKLoginButton _buttonPressed:]_block_invoke + 269
10 FBSDKLoginKit 0x02687bf1 -[FBSDKLoginManager invokeHandler:error:] + 289
11 FBSDKLoginKit 0x02687743 -[FBSDKLoginManager completeAuthentication:expectChallenge:] + 2131
12 FBSDKLoginKit 0x0268b2dc __78-[FBSDKLoginManager(Native) application:openURL:sourceApplication:annotation:]_block_invoke + 108
13 FBSDKLoginKit 0x02681ebf -[FBSDKLoginURLCompleter completeLogIn:withHandler:] + 1183
14 FBSDKLoginKit 0x0268b18c -[FBSDKLoginManager(Native) application:openURL:sourceApplication:annotation:] + 1148
15 FBSDKCoreKit 0x025af16c -[FBSDKApplicationDelegate application:openURL:sourceApplication:annotation:] + 652
16 Snapshot Deals 0x0010b784 _TFC14Snapshot_Deals11AppDelegate11applicationfS0_FTCSo13UIApplication7openURLCSo5NSURL17sourceApplicationGSqSS_10annotationGSqPSs9AnyObject___Sb + 468
17 Snapshot Deals 0x0010b90c _TToFC14Snapshot_Deals11AppDelegate11applicationfS0_FTCSo13UIApplication7openURLCSo5NSURL17sourceApplicationGSqSS_10annotationGSqPSs9AnyObject___Sb + 236
18 UIKit 0x0316269b __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 1160
19 UIKit 0x03161fb5 -[UIApplication _applicationOpenURL:payload:] + 787
20 UIKit 0x03172a11 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 5382
21 UIKit 0x03178cd9 __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 238
22 UIKit 0x03178b83 -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 469
23 UIKit 0x03153e43 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 197
24 UIKit 0x03153a33 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 770
25 FrontBoardServices 0x06cecd23 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke_2 + 71
26 FrontBoardServices 0x06cec65a __40-[FBSSceneImpl _performDelegateCallOut:]_block_invoke + 54
27 FrontBoardServices 0x06d10173 -[FBSSerialQueue _performNext] + 184
28 FrontBoardServices 0x06d105aa -[FBSSerialQueue _performNextFromRunLoopSource] + 52
29 FrontBoardServices 0x06d0f8a6 FBSSerialQueueRunLoopSourceHandler + 33
30 CoreFoundation 0x01c6c6ff CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
31 CoreFoundation 0x01c6238b __CFRunLoopDoSources0 + 523
32 CoreFoundation 0x01c617a8 __CFRunLoopRun + 1032
33 CoreFoundation 0x01c610e6 CFRunLoopRunSpecific + 470
34 CoreFoundation 0x01c60efb CFRunLoopRunInMode + 123
35 GraphicsServices 0x06869664 GSEventRunModal + 192
36 GraphicsServices 0x068694a1 GSEventRun + 104
37 UIKit 0x03156bfa UIApplicationMain + 160
38 Snapshot Deals 0x0010bf9c main + 140
39 libdyld.dylib 0x05371a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Thank you in advance