如何将我的应用程序集成到ios中的“Facebook”应用程序中?

时间:2017-01-17 06:55:39

标签: ios objective-c iphone facebook

如何将我的应用集成到iOS中的facebook应用中? like this screen(jasper app)

2 个答案:

答案 0 :(得分:1)

    #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);
                     }
                 }];
            }
        }

答案 1 :(得分:0)

您要整合的功能称为“Facebook广告”

您需要在Facebook上宣传您的应用。

你可以在google上获得很多答案。

这是您reference的链接。

相关问题