Thursday, 30 April 2015

Facebook Login

Facebook Login



First of All Sign Up Your Facebook Developer Account ...... 


:- > select MyApps Menu On MenuBar & Add a New App:


    In This Select  :-> IOS & Give Unique Name 

    Then Select     :-> Create New Facebook App ID

                            :-> Select NO Option & Choose Category Of App

                                   Create App ID


:->  Download Facebook SDK

:-> Write Bundle Identifier In Supply us with your Bundle         Identifier .....

      to get Bundle Identifier Select :-> General > Identity 
  

:-> At Last Select Login Option ........


Note :-   Your App ID Is Created Here 


:- > select MyApps Menu On MenuBar & Select Your App          
       Name :

   :->    On left Side Menu Select Setting Option Write Your Email 

          ID & Select Save Changes . 

           
  :->    On left Side Menu Select Status & Review  Option  There 

           are One Question Ask Like This...

           Do you want to make this app and all its live 

          features available to the general public?

 
          .......................  Select Yes Option ..................


        Then Dot Sign Near Your App Name Is Automatically 

         Filled With Green Colour .... 


Simply Go to Dashboard Option And Take Your App ID ....

Note :-   Your Work At Facebook Developer Side

              is Complate ....


Note :-  Come In Xcode To Coding ....


 1) First Of all Import Facebook SDK in
 
      Your App :


  2) Go to Supporting File And Select plist 

      File To Write :





3) In App Delegate Import Framework  :


       #import <FacebookSDK/FacebookSDK.h>

:- In didFinishLaunchingWithOptions  method In 

    AppDelegate.m  file 


   Write ->   [FBLoginView class];
                      [FBProfilePictureView class];

EX :-  

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
     [FBLoginView class];
     [FBProfilePictureView class];
    
    return YES;
}

:-> Write Below Method In App Delegate :

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    
    // Call FBAppCall's handleOpenURL:sourceApplication to handle Facebook app responses
    BOOL wasHandled = [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
    
    // You can add your app-specific url handling code here if needed
    
    return wasHandled;
}



  4 ) Make Your Story board Like This :

        
        Put Two View One For Profile Picture & Second For   

        Login In Story Board Given Below  .......




( For Profile Picture View ... Set Class As a FBProfilePictureView )




( For Login View ... Set Class As a FBLoginView )


        :-> Put Two Label For Name And Status :


5 ) Write Coding In View Controller :


ViewController.h :

#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>


@interface ViewController : UIViewController<FBLoginViewDelegate>

    @property (strong, nonatomic) IBOutlet FBProfilePictureView *profilePictureView;
    @property (strong, nonatomic) IBOutlet FBLoginView *LoginView;
    @property (strong, nonatomic) IBOutlet UILabel *nameLabel;
    @property (strong, nonatomic) IBOutlet UILabel *statusLabel;


@end


ViewController.m :


#import "ViewController.h"




@interface ViewController ()

@end

@implementation ViewController
@synthesize profilePictureView,LoginView,nameLabel,statusLabel;

- (void)viewDidLoad
{
    [super viewDidLoad];
    
self.LoginView.readPermissions = @[@"public_profile", @"email", @"user_friends"];
    LoginView.delegate = self;
}

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                            user:(id<FBGraphUser>)user
{
    self.profilePictureView.profileID = user.id;
    self.nameLabel.text = user.name;
}

- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView
{
    self.profilePictureView.profileID = nil;
    self.nameLabel.text = @"";
    self.statusLabel.text= @"You're not logged in!";
}

- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView
{
    self.statusLabel.text = @"You're Under Cover Of Rathod";
}




- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

No comments:

Post a Comment