Ok, finally it is not so hard.
I find this: selecting alternative first view controller from story board at application startup
It's pretty similar, so this is my personal implementation.
Create two views in the storyboard, for me they were named SCViewController and SCLoginViewController (I put the same class name and Storyboard ID).
Then add a navigation controller, and put the arrow that points to the first element displayed on the Navigation Controller.
Than, in the app delegate implementation file, add this to the didFinishLaunchingWithOptions function:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// See if the app has a valid token for the current state.
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// Yes, so just open the session (this won't display any UX).
[self openSession];
} else {
// No, display the login page.
[self showLoginView];
}
return YES;
}
And add the function:
- (void)showLoginView
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *sbFile = [bundle objectForInfoDictionaryKey:@"UIMainStoryboardFile"];
UIStoryboard *sb = [UIStoryboard storyboardWithName:sbFile bundle:bundle];
UIViewController *rootController;
rootController = [sb instantiateViewControllerWithIdentifier:@"SCLoginViewController"];
[self.window setRootViewController:rootController];
}
If you are logged when you open the app, you arrive on SCViewController, otherwise you arrive on SCLoginViewController.
You can then follow the iOS tutorial from Facebook (app Scrumptious) as if you were using .xib files: https://developers.facebook.com/docs/ios/ios-sdk-tutorial/.
Don't forget to create the following properties:
@property (strong, nonatomic) UINavigationController* navController;
@property (strong, nonatomic) SCViewController *mainViewController;
and to import:
#import <FacebookSDK/FacebookSDK.h>
#import "SCLoginViewController.h"
#import "SCViewController.h"