Facebook login Fault 3100

Hi,

I’m unable to login to my account using Facebook. It was working fine this morning. Made no code changes. Current user prints fine. User exists in the database. Please see attached screenshot.
http://support.backendless.com/public/attachments/a210015a9fc26c4527e1818607b16155.png</img>

Hi Mike,

Which method from our SDK do you use to login the user?

Mark

Hi Mark,

This is the code I’m using for login. I’m using the Facebook SDK and not the easy login.

FBSDKAccessToken *accessToken = [FBSDKAccessToken currentAccessToken];
 [backendless.userService loginWithFacebookSDK:accessToken fieldsMapping:nil response:^(BackendlessUser *user) { 
 
 NSDictionary *requestParameters = [NSDictionary dictionaryWithObject:@"id, email, first_name, last_name, name, picture.width(640).height(640)" forKey:@"fields"]; 
 [[[FBSDKGraphRequest alloc]initWithGraphPath:@"me" parameters:requestParameters]startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
 if(!error) 
 { 
 //NSLog(@"fetched user:%@", result); 
 } 
 if (result != nil) { 
 fbuserId = [result objectForKey:@"id"]; 
 email = [result objectForKey:@"email"]; 
 firstName = [result objectForKey:@"first_name"]; 
 lastName = [result objectForKey:@"last_name"]; 
 fbPic = [[[result valueForKey:@"picture"] valueForKey:@"data"] valueForKey:@"url"]; 
 
 [user setProperty:@"name" object:[NSString stringWithFormat:@"%@ %@", firstName, lastName]]; 
 [user setProperty:@"FBUserID" object:fbuserId]; 
 
 NSString *messagingChannel = @"ios"; 
 NSString *registeredDevice = [backendless.messaging registerDevice:@[messagingChannel]]; 
 NSLog(@"registered device: %@", registeredDevice); 
 
 [user setProperty:@"deviceId" object:registeredDevice]; 
 
 [backendless.userService update:user]; 
 } 
 }]; 
 
 } error:^(Fault *fault) { 
 NSLog(@"Error registering user %@", fault); 
 }];


}

At what point does the error occur? When you call what method?

It happens when I call the following method.









 [backendless.userService isValidUserToken:^(NSNumber *result) {

        NSLog(@"isValidUserToken (ASYNC): %@", [result boolValue]?@"YES":@"NO");

        if ([result boolValue] == YES) {

            [self callHomePage];

        }

        else if([result boolValue] == NO)

        {

            NSLog(@"User not logged in");

        }

    }

    error:^(Fault *fault) {

        NSLog(@"login FAULT (ASYNC): %@", fault);

    }];

I have checked if the current user is logged in before I call the above method, using









NSLog(@"Current user: %@", [backendless.userService currentUser]);

And It tells me the user is logged in and shows me all the current user details.

The error is thrown at backendless.userService isValidUserToken.

Assigning it to a developer. This is quite puzzling for me.

Hi Mike,

We looked into it and the problem has already been fixed in the latest build. Please update the library either from the github repository or using our pod from CocoaPods.

Regards,
Mark

Hi Mark,

I have just updated the library.(I hope it’s just copying the lib folder to my project root. Not using cocoapods).
The issue has not been fixed. I’m still unable to login.

Hi Mike,

The issue I was talking about is when the isValidUserToken method used to throw an exception. Is this still what you experienced in your app?

Regards,
Mark

Hi Mark,

Now the login issue seems to be intermittent. Some times it logs me in, sometimes it doesn’t. I tried deleting the user on the console and also deleted the app and rebuilt.
I have a new problem now. It takes a full minute to get a response from isValidToken method!! Is there any limits on the developer account? Or am I having 2 bad days in a row?

Hi Mike,

We have FacebookLogin sample in our Backendless iOS-Samples github (you could clone it): it makes Facebook SDK Login and checks ‘isValidUserToken’ every 60sec.

I just tried - it works fine for me. Here is an app log:
http://support.backendless.com/public/attachments/b4724d6ea94eb1731b3d5efd2df81867.png</img>
Please try it too with your appID & secretKey - and let me know how it goes.

Regards,
Slava

HI Slava,

I changed my code to use the SYNC method and I’m able to login.
I checked the github code and it looks like its using a SYNC method.
Could you please verify with the ASYNC method once? Its blocking my UI.

I changed the sample method with async call:

-(void)checkValidUserToken {
    
#if 0
    NSLog(@"%@: Is UserToken Valid? %@", [NSDate date], [backendless.userService isValidUserToken].boolValue?@"YES":@"NO");
#else
    [backendless.userService isValidUserToken:
     ^(NSNumber *result) {
         NSLog(@"%@: Is UserToken Valid? %@", [NSDate date], result.boolValue?@"YES":@"NO");
     }
     error:^(Fault *fault) {
        NSLog(@"%@", fault);
     }];
#endif
    
    dispatch_time_t interval = dispatch_time(DISPATCH_TIME_NOW, 1ull*NSEC_PER_SEC*60);
    dispatch_after(interval, dispatch_get_main_queue(), ^{
        [self checkValidUserToken];
    });
}

and it works fine too.

Maybe this use case will be helpful for your UI:

    [backendless.userService isValidUserToken:
     ^(NSNumber *result) {
         NSLog(@"%@: Is UserToken Valid? %@", [NSDate date], result.boolValue?@"YES":@"NO");
         
         dispatch_async( dispatch_get_main_queue(), ^{
             // some UI code
         });


     }
     error:^(Fault *fault) {
        NSLog(@"%@", fault);
     }];

Seems like async method is blocking my UI also

Hi Khoo,

Please clarify:

  • what “async method is blocking your UI”,
  • could you give us some code,
  • could you send your sample project, demonstrated the problem, to support@backendless.com.
    To help you we need to reproduce the issue you’ve described.

Regards,
Slava

I dont knwo why it just working perfectly before the problem of sorted , after the sorted problem fixed i have another problem is that it work fast on stimulator but on my iphone it fetch very slow and the query is making cannot change my tab .Here my code . It stuck for a while like 5 minutes maybe and only query .

 
 
 
 
 
 
 
 
func fetchFollowUsers(){
 
 
 
 
 
 print("Likes \(self.likes)") 
 
 
 
 
 print("\n============ Fetching first page using the ASYNC API ============") 
 
 
 
 
 
 let startTime = NSDate() 
 
 let whereClause = "type = 'follow' AND fromUser.objectId = '\(backendless.userService.currentUser.objectId)'" //User Can Be Query Through Object ID 
 
 let followQuery = BackendlessDataQuery() 
 
 followQuery.whereClause = whereClause 
 
 var followObjectId = [String]() 
 
 
 
 let queryOptions = QueryOptions() 
 
 
 
 queryOptions.addRelated("toUser") 
 
 queryOptions.addRelated("fromUser") 
 
 followQuery.queryOptions = queryOptions 
 
 /* 
 
 let queryOptions = QueryOptions() 
 
 queryOptions.addRelated("fromUser") 
 
 
 
 let dataQuery = BackendlessDataQuery() 
 
 dataQuery.whereClause = whereClause 
 
 dataQuery.queryOptions = queryOptions 
 
 */ 
 
 
 
 print("Should Load Here First") 
 
 //FIrst We Get All User Object id That User Have Follow 
 
 //Get All User Object Id That Follow 
 
 backendless.persistenceService.of(Activity.ofClass()).find( 
 
 followQuery, 
 
 response: { ( restaurants : BackendlessCollection!) -> () in 
 
 let currentPage = restaurants.getCurrentPage() 
 
 print("Loaded \(currentPage.count) Follow USer objects") 
 
 print("Total Follow User in the Backendless starage - \(restaurants.totalObjects)") 
 
 
 
 for followUsers in currentPage as! [Activity] { 
 
 
 
 followObjectId.append((followUsers.toUser?.objectId)!) 
 
 
 
 } 
 
 
 
 var whereClauseStatus = String() 
 
 
 
 whereClauseStatus = "user.objectId = '\(backendless.userService.currentUser.objectId)'" //User Can Be Query Through Object ID 
 
 
 
 
 if currentPage.count != 0 { 
 
 
 
 //Get All Image From Follow User 
 
 for var i = 1 ; i <= currentPage.count ; i++ { 
 
 print(currentPage.count) 
 
 whereClauseStatus = whereClauseStatus + "OR user.objectId = '\(followObjectId[i-1])' " 
 
 } 
 
 
 
 
 
 let followQueryStatus = BackendlessDataQuery() 
 
 followQueryStatus.whereClause = whereClauseStatus 
 
 
 
 
 
 print("Follow Object id = \(followObjectId)") 
 
 let queryOptionsStatus = QueryOptions() 
 
 queryOptionsStatus.addRelated("user") 
 
 queryOptionsStatus.sortBy(["created DESC"]) 
 
 queryOptionsStatus.pageSize = 50 
 
 followQueryStatus.queryOptions = queryOptionsStatus 
 
 
 
 
 
 
 //We Then Get All Follow USer Status And Current User Status From It 
 
 backendless.persistenceService.of(Status.ofClass()).find( 
 
 followQueryStatus, 
 
 response: { ( restaurants : BackendlessCollection!) -> () in 
 
 let currentPage2 = restaurants.getCurrentPage() 
 
 print("Loaded \(currentPage2.count) follow objects") 
 
 print("Total Follow Status in the Backendless starage - \(restaurants.totalObjects)") 
 
 
 
 for followStatus in currentPage2 as! [Status] { 
 
 
 
 
 
 print("Object \n Restaurant name = \(followStatus.status!)") 
 
 self.status.append(followStatus.status!) 
 
 
 
 
 
 print("Check From User IS NIL\(followStatus.user?.name)") 
 
 self.user.append((followStatus.user?.name!)!) 
 
 print("Checking Date \(followStatus.created) \n") 
 
 self.date.append(followStatus.created!) 
 
 self.statusId.append(followStatus.objectId!) 
 
 print("Status ObjectId Array = \(self.statusId)") 
 
 self.objectCount++ 
 
 } 
 
 
 
 self.loadUserStatus() 
 
 
 
 
 }, 
 
 error: { ( fault : Fault!) -> () in 
 
 print("Server reported an error: --> from Photo Follows \(fault)") 
 
 } 
 
 
 
 
 
 ) 
 
 self.imageView.removeFromSuperview() 
 
 
 
 
 print("Follow Object Id == \(followObjectId)") 
 
 
 
 
 
 }else /*From Current Page != 0 */ { 
 
 
 
 let followQueryStatus = BackendlessDataQuery() 
 
 followQueryStatus.whereClause = whereClauseStatus 
 
 
 
 
 
 print("Follow Object id = \(followObjectId)") 
 
 let queryOptionsStatus = QueryOptions() 
 
 queryOptionsStatus.addRelated("user") 
 
 queryOptionsStatus.sortBy(["created DESC"]) 
 
 queryOptionsStatus.pageSize = 50 
 
 followQueryStatus.queryOptions = queryOptionsStatus 
 
 
 
 
 
 //We Then Get All Follow USer Status And Current User Status From It 
 
 backendless.persistenceService.of(Status.ofClass()).find( 
 
 followQueryStatus, 
 
 response: { ( restaurants : BackendlessCollection!) -> () in 
 
 let currentPage2 = restaurants.getCurrentPage() 
 
 print("Loaded \(currentPage2.count) follow objects") 
 
 print("Total Follow Status in the Backendless starage - \(restaurants.totalObjects)") 
 
 
 
 for followStatus in currentPage2 as! [Status] { 
 
 
 
 
 
 print("Object \n Restaurant name = \(followStatus.status!)") 
 
 self.status.append(followStatus.status!) 
 
 
 
 
 
 print("Check From User IS NIL\(followStatus.user?.name)") 
 
 self.user.append((followStatus.user?.name!)!) 
 
 print("Checking Date \(followStatus.created) \n") 
 
 self.date.append(followStatus.created!) 
 
 self.statusId.append(followStatus.objectId!) 
 
 print("Status ObjectId Array = \(self.statusId)") 
 
 self.objectCount++ 
 
 } 
 
 
 
 self.loadUserStatus() 
 
 
 
 }, 
 
 error: { ( fault : Fault!) -> () in 
 
 print("Server reported an error: --> from Photo Follows \(fault)") 
 
 } 
 
 
 
 
 
 ) 
 
 
 
 } 
 
 }, 
 
 error: { ( fault : Fault!) -> () in 
 
 print("Server reported an error: -> Follow Users Function \(fault)") 
 
 
 
 //Need Add View To Refresh When Request Time Out 
 
 
 
 
 
 } 
 
 
 
 ) 
 
 
 
 
 } 
 
 


i dont know why but in stimulator i can navigate through any tab bar while loading but on my phone it just cant

your iPhone connection is via wi-fi or via mobile net?