4

I am developing an ios phonegap application. For registration i use phonegap facebook plugin. It worked fine for the first time. But now when i try to register it isn't working. I haven't changed anything. I use Xcode version 4.6.1 and cordova version 2.4.0.

enter image description here

Figure shows my Facebook developers page.

What am i doing wrong?

Please help, Thanks.

Erma Isabel
  • 2,167
  • 8
  • 34
  • 64

6 Answers6

9

I think this will fix your issue:

  1. Go to you Facebook app in your Facebook account.
  2. Click edit your app.
  3. Go to Basic info tab.
  4. Sandbox Mode: check this as Disable
  5. Save the setting.

This will work for you.

Vinod Singh
  • 1,374
  • 14
  • 25
  • Thanks, but, you know why the sandbox does not worked properly? – GodFather Jun 03 '13 at 21:45
  • 2
    I think because Facebook login functionality works on SSO (Single Sign On). our app get redirect to Facebook app (if exist) in the device and take all information from there without making login separate for each app. I think this should be the reason. – Vinod Singh Jun 04 '13 at 07:28
6

First of all make sure about your Bundle Id should be correct.

And change your setting like it

enter image description here

Change sandbox setting disabled.

Also change your P-list setting like it

enter image description here

It will work fine. If you will face this problem again please let me know.

chandan
  • 2,453
  • 23
  • 31
  • Still same error. I did every thing as you mentioned. What do i do now? – Erma Isabel Apr 17 '13 at 05:41
  • Check your bundle identifier in your project P-list. It should be same as you mentioned in developers.facebook.com. – chandan Apr 17 '13 at 05:46
  • Also add this two thing in your project plist 1.> URL Type item 0(Editor) Document Role : Editor URL identifier : Your bundle Id URL Schemes Item 0 : fb"plus your app secret key " Item 1 : Your bundle Id 2.> FacebookAppID : "your app secret key" – chandan Apr 17 '13 at 05:55
  • Initially, i populated the fields you mentioned with "AppId" , Now changed to "App Secret Key". Now when i click "Register with facebook" button "Error occured. Please try again later" message is showing. – Erma Isabel Apr 17 '13 at 06:09
  • First of all delete app and reinstall it in your device . Then follow P-List change from above given image. and check your code with this given link http://stackoverflow.com/questions/12838118/facebook-authorization-fails-on-ios6-when-switching-fb-account-on-device – chandan Apr 17 '13 at 06:16
  • I get warning "Access token is depreciated". Is it a problem? – Erma Isabel Apr 17 '13 at 07:04
  • Sorry change app secret key with app id. It work fine for you – chandan Apr 17 '13 at 07:41
  • Hello , i can follow this all step but when i can send message to friends wall , then i get error , please give me solution of this problem.... Error: HTTP status code: 403 Error: The operation couldn’t be completed. (com.facebook.sdk error 5.) – vijay May 06 '13 at 11:21
  • This is due to lack of permissions. Allow publish_actions permissions to post messages. – chandan May 06 '13 at 11:53
1

If you get warning "Access token is depreciated". Please add or replace your code line by this two lines where you are passing permissions to your app

[FBSession.activeSession closeAndClearTokenInformation]; 

NSArray *permissions = [NSArray arrayWithObjects:@"email", nil];

If u are doing all the thing right then please check "status" value. If it is 257 then please enable your app in your IPhone facebook settings.

Here is the code that can help you to understand in better way

   [FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:^(FBSession *session,
                                                                                                     FBSessionState status, NSError *error)
     {
      if (error)
      {
              NSLog(@"error===%@   status====%u",error,status);
              // Handle errors
                 [self handleAuthError:error];
         }
         else if (FB_ISSESSIONOPENWITHSTATE(status))
         {
             [self getData];
         }
     }];


-(void)handleAuthError:(NSError *)error{
    NSString *alertMessage, *alertTitle;

    if (error.fberrorShouldNotifyUser) {
        // If the SDK has a message for the user, surface it.
        alertTitle = @"Something Went Wrong";
        alertMessage = error.fberrorUserMessage;
    } else if (error.fberrorCategory == FBErrorCategoryUserCancelled) {
        // The user has cancelled a login. You can inspect the error
        // for more context. For this sample, we will simply ignore it.
        NSLog(@"user cancelled login");
    } else {
        // For simplicity, this sample treats other errors blindly.
        alertTitle  = @"Unknown Error";
        alertMessage = @"Error. Please try again later.";
        NSLog(@"Unexpected error:%@", error);
    }

    if (alertMessage) {
        [[[UIAlertView alloc] initWithTitle:alertTitle
                                    message:alertMessage
                                   delegate:nil
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil] show];
    }
}

I hope it would work.

chandan
  • 2,453
  • 23
  • 31
  • I am getting status == 257 isn't there any other way to make app works without enable it in Settings in Facebook? I'm using Facebook SDK only because I wan't to let use my app for users that have disabled Facebook in Settings – Michal Gumny Aug 27 '13 at 23:20
  • Hi @Michal, i have resolved your problem. I have updated my code . Please check it and let me know if any problem occurs. Thanks – chandan Aug 28 '13 at 05:14
  • Facebook SDK is messy as **** This 2 lines of code didn't help. But funny thing - app didn't work on iPod but did work on iPhone 5 with identical settings, after I reinstalled Facebook app on iPod it started working fine. I think it's very very hard do predict all possible situations that can occur with Facebook SDK. In other hand iOS Social Framework works great but often people disable Facebook in Settings. – Michal Gumny Aug 28 '13 at 16:14
0

There is also a case when you have 2 or more items in the URL types array in your info.plist. The Facebook related item should be the first, otherwise you get the error 2. This is probably a Facebook SDK bug.

Marko Hlebar
  • 1,973
  • 17
  • 18
0

This worked for me:

Go to the settings app of your iPhone. Open your Facebook Settings Scroll down to your app and make sure your app allows facebook interaction.

Hitesh Vaghela
  • 1,635
  • 1
  • 11
  • 11
0

Download Facebook new version and it should work. I had same error with sdk version 3.13.1.Then, I replaced it with sdk version 3.14.1. Then, it worked for me.

Lasang
  • 1,369
  • 6
  • 24
  • 44