简体   繁体   中英

how to integrate my app into `Facebook` app in ios?

How to integrate my app into facebook app in iOS? like this screen(jasper app)

    #import <FBSDKLoginKit/FBSDKLoginKit.h>
    #import <FBSDKCoreKit/FBSDKCoreKit.h>   

 //Download facebook from facebook developer site and implement the following methods.

     -(void)doLoginInFacebook:(UIViewController *)viewController
        {
            FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
            [login logOut];
            [login setLoginBehavior:FBSDKLoginBehaviorSystemAccount];
            [login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
             {
                 if (error)
                 {
                     //NSLog(@"Error===%@",error);
                 }
                 else if (result.isCancelled)
                 {
                     // Handle cancellations
                 }
                 else
                 {
                     //NSLog(@"result is:%@",result);


                     if ([result.grantedPermissions containsObject:@"email"])
                     {
                         [self fetchUserInfoWithViewController:viewController];
                     }
                     else
                     {
                         [self fetchUserInfoWithViewController:viewController];

                     }
                 }
             }];

        }
        -(void)fetchUserInfoWithViewController:(UIViewController *)ViewController
        {
            if ([FBSDKAccessToken currentAccessToken])
            {
                //NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);

                [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location ,friends ,hometown , friendlists"}]
                 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                     if (!error)
                     {
                         NSMutableDictionary *dic=result;
                         //NSLog(@"%@",dic);

                         if (self.delegate && [self.delegate respondsToSelector:@selector(doGetFacebookUserInfo:)] )
                         {
                             [self.delegate doGetFacebookUserInfo:dic];
                         }
                     }
                     else
                     {
                         // [self.delegate doGetFacebookUserInfo:nil];
                         //NSLog(@"Error %@",error);
                     }
                 }];
            }
        }

The functionality that you want to integrate is known as "Facebook Advert" .

You need to advertise your app in facebook.

You can get many answer for this in google.

This is the link for your reference .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM