I have an application in xcode 4, and I need to use the Facebook’s username and password to authenticate and access my application. Only want to use Facebook login and Password for login to application. After login successful should be open our iPhone application.
How I can do this?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
facebook = [[Facebook alloc] initWithAppId:@"211846395591747" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil];
}
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
NSLog(@"handleOpenURL");
return [facebook handleOpenURL:url];
}
I did this code for Facebook connectivity. It’s opening our Facebook developer’s project page. i want only use Facebook username and password for login to my application.
Please help me.
you need to create Bool method which get Facebook loggin is done or Not,u have to setup this function first view,if login is not done then show alert box this link can solve your problem
application login with facebook login