Social login in Swift

Hi,
I was trying to connect social accounts based on docs -> https://backendless.com/documentation/users/ios/users_facebook_login.htm
But I’m facing with issue :
<Logging: 0x7f9bd851dbf0>
2016-03-25 15:56:53.512 backendless_training[21431:856417] *** 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 0x000000010ce7dd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c8f1deb objc_exception_throw + 48
2 CoreFoundation 0x000000010cd36a52 -[__NSPlaceholderArray initWithObjects:count:] + 290
3 CoreFoundation 0x000000010cd930b4 +[NSArray arrayWithObjects:count:] + 52
4 backendless_training 0x00000001087cb447 -[UserService loginWithFacebookSocialUserId:accessToken:expirationDate:permissions:fieldsMapping:responder:] + 215
5 backendless_training 0x00000001087ca28d -[UserService loginWithFacebookSDK:fieldsMapping:responder:] + 171
6 backendless_training 0x00000001084b58e0 _TFC20backendless_training11AppDelegate11applicationfTCSo13UIApplication7openURLCSo5NSURL17sourceApplicationGSqSS_10annotationPs9AnyObject__Sb + 2608
7 backendless_training 0x00000001084b5df0 _TToFC20backendless_training11AppDelegate11applicationfTCSo13UIApplication7openURLCSo5NSURL17sourceApplicationGSqSS_10annotationPs9AnyObject__Sb + 272
8 UIKit 0x000000010afad528 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke + 1018
9 UIKit 0x000000010afacedd -[UIApplication _applicationOpenURL:payload:] + 729
10 UIKit 0x000000010afbb933 -[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:] + 2024
11 UIKit 0x000000010afc1f0a __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke + 214
12 UIKit 0x000000010afc1dde -[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:] + 508
13 UIKit 0x000000010afa08a0 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 159
14 UIKit 0x000000010afa052d -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 843
15 FrontBoardServices 0x000000010f3648c8 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24
16 FrontBoardServices 0x000000010f364741 -[FBSSerialQueue _performNext] + 178
17 FrontBoardServices 0x000000010f364aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
18 CoreFoundation 0x000000010cda3301 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
19 CoreFoundation 0x000000010cd9922c __CFRunLoopDoSources0 + 556
20 CoreFoundation 0x000000010cd986e3 __CFRunLoopRun + 867
21 CoreFoundation 0x000000010cd980f8 CFRunLoopRunSpecific + 488
22 GraphicsServices 0x000000010eeb9ad2 GSEventRunModal + 161
23 UIKit 0x000000010afa2f09 UIApplicationMain + 171
24 backendless_training 0x00000001084b6b42 main + 114
25 libdyld.dylib 0x000000010d8ad92d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Hi Edis,

You could try our Social Logins sample (it is with our appId & secretKey) - it works fine for me. Check it, and if it’s alright, you could rewrite this sample in Swift.

BTW: you could clone all iOS-Samples github repo - it contains some samples, hope it will be helpful for you.

Regards,
Slava

I just created FacebookLoginSwift sample - it works fine for me, you could try it and let we know how it goes.

It was created with CocoaPods, so you will load the project with .xcworkspace file.
If you change appID & secretKey to yours, you also should change appId value in Info.plist ‘URL types → URL Schemes’:
http://support.backendless.com/public/attachments/72aa8b34bd53cba94fa48fdb2d7a46be.png&lt;/img&gt;

Regards,
Slava

Thank you.

Please can you provide me more details, while trying to GO-TO facebook it shows URL blocked…I have searched but no results…

FYI I’m using localhost server

What do you mean - “localhost server”? Have you set up Backendless locally?

Could you provide some screenshots, etc.

Hi, thank you for fast reply…

http://support.backendless.com/public/attachments/6eaf7229ae58340860c258fb14063b75.png&lt;/img&gt;

http://support.backendless.com/public/attachments/2ce809c434ecf14a70381c618130bd10.png&lt;/img&gt;

http://support.backendless.com/public/attachments/283dbdf5e8d3c2f3da2d103e9557f2c4.png&lt;/img&gt;

So in stackoverflow some say that I should give a http permission in info.plist, so I did. nothing happens.

Here are some changes I did in Facebook developer page regarding docs.

http://support.backendless.com/public/attachments/a35af3bc156789677ecb775767e2e0dc.png&lt;/img&gt;

http://support.backendless.com/public/attachments/e35899f107a353d122c7ec670341e9f0.png&lt;/img&gt;

The app domain URL is not correct. It must be api.backendless.com:
http://support.backendless.com/public/attachments/6327a991531746607c69334284eebe27.jpg&lt;/img&gt;

The “OAuth redirect URI” is also incorrect. Facebook have no idea how to get to the url you specified.

Mark

O GOD :frowning: …I thought I write it correctly… Thank you