How to redirect to iphone app from facebook login

In my iphone app redirect to facebook login like facebook app when clicking a button. After login again redirect to my app.

i'm using this code

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

[FBSession openActiveSessionWithReadPermissions:permissions
                                   allowLoginUI:YES
                              completionHandler:
 ^(FBSession *session,
   FBSessionState state, NSError *error) {

     if(!error)
     {
         NSLog(@" hi im sucessfully lloged in");
     }
 }];

Answers


in your you AppDelegate modify the method

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url  
{

NSString *urlString = [url absoluteString];

if ([urlString hasPrefix:@"fb://xxxxxxxxxxxx"]) {
    [FBSession.activeSession handleOpenURL:url];
    returnValue = YES;
}

return returnValue;
}  

also

But keep in mind that this is not triggered in IOS 6.In ios 6 the following method will be triggered.

 - (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
 sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation {

return [FBSession.activeSession handleOpenURL:url];
 }

If the state of your session changes due to login or disconnect FBsession calls the following method and you should handle your cases.

- (void)sessionStateChanged:(FBSession *)session
                  state:(FBSessionState)state
                  error:(NSError *)error {
switch (state) {
    case FBSessionStateOpen: {
        //update permissionsArrat
        [self retrieveUSerPermissions];

        if (!needstoReopenOldSession) {
            //First User information
            [self getUserInformation:nil];
        }

        NSNotification *authorizationNotification = [NSNotification notificationWithName:facebookAuthorizationNotification object:nil];
        [[NSNotificationCenter defaultCenter] postNotification:authorizationNotification];

    }
    case FBSessionStateClosed: {
        break;
    }
    case FBSessionStateClosedLoginFailed: {
        [FBSession.activeSession closeAndClearTokenInformation];
        break;
    }
    default:
        break;
}

if (error) {
    NSNotification *authorizationNotification = [NSNotification notificationWithName:faceBookErrorOccuredNotification object:nil];
    [[NSNotificationCenter defaultCenter] postNotification:authorizationNotification];
}
}

Need Your Help

ASP.NET - Easy way to swap a boolean?

c# asp.net datagrid

Background: I am using ASP.NET 2.0 (with C#) and the code below is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.