1

basically my app uses safari to log in to facebook ive but the logout isnt proper ive used session closeandcleartoken in the appdidfinishlaunching and at a buttonaction but somehow the session is still there and it doesnt prompt the user to login thier name again and directly gives access to facebook page

Ramiz Girach
  • 169
  • 2
  • 10

1 Answers1

1

could you please check these two links below, hope it help

facebook-ios-sdk logout question

Understanding NSHTTPCookieStorage for the iPhone

OLD UPDATE (see new update below): I think the following link may be useful to you, please try and give me a feedback, thanks.

Is it possible to change iOS Safari settings programmatically

NEW UPDATE: //because we cannot clear cace of safari, so this is the idea that may be useful for you. //The concept is -> in your app, you need to create settings page(to check that in iphone's setting, is there any facebook account? if yes you can post image to facebook(you may use uiswitch, when user switch facebook service to turn on, it will check in iphone's settings menu that, is there any facebook account? if yes you can switch on facebook service)). Then you need to create the "share page", in "share page" will check that in your app's setting page, the facebook service is turn on or not?, if yes, then you can share image to facebook, so we can say that in share page will has a code of sharing image to facebook, and in your app's setting page should look similar to the following. So we just let user log in and log out facebook in iphone setting, and we just check user's account from iphone's setting, so you don't have to headache with facebook logout problem anymore :), in ios 5 there are no facebook in iphone's setting, so you have no choice, I look for the solution from popular app in app store, and I come out with this solution please look the code below, hope it help, actually I already answered your scope of question already, so this is something like extend question, so next time please post a new question, hope it at least guide you to the right path :).

- (void) facebookAuthen 
{
    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:@"com.apple.facebook"];

    if (accountType == nil) { // ios lower than 6
        if (FBSession.activeSession.isOpen) {
            [appDelegate closeSession];
            NSLog(@"session close");
        } else {
            [appDelegate openSessionWithAllowLoginUI:YES];
            NSLog(@"open session");
        }
    }
    else { // ios 6
        NSDictionary* options = [NSDictionary dictionaryWithObject:@"your facebook id" forKey:ACFacebookAppIdKey];
        [accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error) {
            if(granted) { //has an account in iphone's setting
                // do something 
            }
            else {
                // show alert
            }
        }];
    }
}
Community
  • 1
  • 1
piam
  • 653
  • 6
  • 13
  • have you try this already ? – piam Nov 16 '12 at 11:55
  • @RamizGirach , I update the answer please see hope it helpful for you :) – piam Nov 16 '12 at 12:36
  • yes piam i have tried every thing clear NSHTTPCOOKIE also USERDEFAULTS but nothing is happening but i think its because my app is using safari to login into facebook and obviously u cant clear safari's cache so i have to find another way a native dialog or something to login in to facebook ... if u have any other idea please post .. thanx – Ramiz Girach Nov 17 '12 at 06:44
  • yes, @RamizGirach , according to the link above that I gave you, there is no way to clear safari's cache, for my other idea to solve this problem is to have a setting page like in "line" application, before you post something to facebook you have to login first but the application will check that you are log in or not from the iphone's settings menu. //please see my update :) – piam Nov 18 '12 at 07:17