Skip to content

Instantly share code, notes, and snippets.

@martinnormark
Created April 21, 2013 07:19
Show Gist options
  • Select an option

  • Save martinnormark/5428762 to your computer and use it in GitHub Desktop.

Select an option

Save martinnormark/5428762 to your computer and use it in GitHub Desktop.
Modified the iOS + Facebook sample from: https://parse.com/tutorials/integrating-facebook-in-ios
//
// Copyright (c) 2013 Parse. All rights reserved.
#import "AppDelegate.h"
#import <Parse/Parse.h>
#import "LoginViewController.h"
#import "UserDetailsViewController.h"
@implementation AppDelegate
#pragma mark - UIApplicationDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// ****************************************************************************
// Fill in with your Parse credentials:
// ****************************************************************************
[Parse setApplicationId:@"id" clientKey:@"key"];
// ****************************************************************************
// Your Facebook application id is configured in Info.plist.
// ****************************************************************************
[PFFacebookUtils initializeFacebook];
// Override point for customization after application launch.
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[UserDetailsViewController alloc] init]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
LoginViewController *lvc = [[LoginViewController alloc] init];
[self.window.rootViewController presentViewController:lvc animated:YES completion:nil];
return YES;
}
// ****************************************************************************
// App switching methods to support Facebook Single Sign-On.
// ****************************************************************************
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [PFFacebookUtils handleOpenURL:url];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
[FBSession.activeSession handleDidBecomeActive];
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
[FBSession.activeSession close];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment