How to redirect on app after successfull facebook login in iOS5
-
06-07-2021 - |
Question
There is a facebook button in my app in login screen ,when user click on this button facebook login page open in browse and after successful login application redirect and display next page . Please hep mw with example .
IOS version : 5.0 ARC project
Thank You
Solution
by the way you guys can visit my reply here Native iOS Facebook SSO won't return to app
In my application i had to implement facebook and googleplus both and finally I made it successfully. I dont think facebook developer app portal needs any edit rather than getting appid. I made three apps with facebook login, one of them does not have iOS Native App setting in facebook developer app but that app's login part is also running well.
OTHER TIPS
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;
}
xxx will be your facebookappid
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];
}
}
Use this official tutorial and you will be OK. See the 2-d point for your problem as well.