2013-01-10 4 views
0

페이스 북 통합을 위해 FAcebook SDK 3.0을 사용합니다. 샘플 코드 "HelloFacebookSample" 을 사용하여 상태를 게시했습니다. AppId에서 Info.plist 파일을 변경했습니다. 나는 show armv7s, armv7 architecture problem.I 문제를 가지고있다. 심지어 YEs에 "Build Active Architecture Only"로 해결한다. (있는 UIButton *) 보낸 사람 : (IBAction를) postStatusUpdateClick -ios5 및 6 페이스 북의 SDK와 아이폰의 페이스 북 통합

나는 페이스 북

#import "HFViewController.h" 

#import "AppDelegate.h" 
#import <CoreLocation/CoreLocation.h> 


@interface HFViewController() <FBLoginViewDelegate> 


@property (strong, nonatomic) IBOutlet UIButton *buttonPostStatus; 

@property (strong, nonatomic) id<FBGraphUser> loggedInUser; 

- (IBAction)postStatusUpdateClick:(UIButton *)sender; 


- (void)showAlert:(NSString *)message 
     result:(id)result 
     error:(NSError *)error; 


@end 

@implementation HFViewController 
@synthesize shareStringFb; 
@synthesize buttonPostStatus = _buttonPostStatus; 

@synthesize loggedInUser = _loggedInUser; 


- (void)viewDidLoad {  
[super viewDidLoad]; 

// Create Login View so that the app will be granted "status_update" permission. 
self.buttonPostStatus.enabled = YES; 

FBLoginView *loginview = [[FBLoginView alloc] init]; 

loginview.frame = CGRectOffset(loginview.frame, 5, 5); 
loginview.delegate = self; 

[self.view addSubview:loginview]; 

[loginview sizeToFit]; 
statusText.text=self.shareStringFb; 
{ 
    // if the session is closed, then we open it here, and establish a handler for state changes 
} 

}

-(IBAction)backClick:(id)sender 
{ 
[self.view removeFromSuperview]; 

} 

- (void)viewDidUnload { 

self.buttonPostStatus = nil; 

self.loggedInUser = nil; 

[super viewDidUnload]; 
} 



- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView { 
// first get the buttons set for login mode 

    self.buttonPostStatus.enabled = YES; 

} 

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView 
         user:(id<FBGraphUser>)user { 
// here we use helper properties of FBGraphUser to dot-through to first_name and 
// id properties of the json response from the server; alternatively we could use 
// NSDictionary methods such as objectForKey to get values from the my json object 

self.loggedInUser = user; 
} 

- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView { 

    self.buttonPostStatus.enabled = NO; 

    } 

// 후 상태 업데이트 버튼 핸들러 에 대한 로그인/로그 아웃에 대한 버튼을 보여 코드를 {

// Post a status update to the user's feed via the Graph API, and display an alert view 
// with the results or an error. 

NSString *message = [NSString stringWithFormat:@"Updating %@'s status at %@", 
        self.loggedInUser.first_name, [NSDate date]]; 

[FBRequestConnection startForPostStatusUpdate:self.shareStringFb 
          completionHandler:^(FBRequestConnection *connection, id   result, NSError *error) { 

           [self showAlert:message result:result error:error]; 
           self.buttonPostStatus.enabled = YES; 
          }]; 

self.buttonPostStatus.enabled = NO;  

}

// 사진 게시 버튼 핸들러

시뮬레이터에서 로그인/로그 아웃과 함께 하나의 버튼이 표시되지만, 기기에서 테스트 할 때 버튼이 표시되지 않습니다.

문제가 무엇인지 알려주시겠습니까? 보이지 않는 이유는 무엇입니까? 5와 6 모두에서 Fb를 통합 할 수있는 다른 방법이 있습니까?

+1

페이스 북 통합을위한 내장 기능에있다. .. – Vishal

+0

우리가 당신을 도울 수 있도록 더 많은 코드를 게시해야합니다. – jakenberg

+0

@jinal 헤이 친애하는 vishal 오른쪽 .. 여기에 당신은 ios5에서 트위터와 같은 페이스 북에 대한 inbult 프레임 워크를 얻을 수 있습니다 당신이 내 대답을 받아 들일 수있는 당신이 유용한 줄 ?? –

답변

0
ViewController.h 

    #import <FacebookSDK/FacebookSDK.h> 

    { 
    NSDictionary *dictionary; 
     NSString *user_email; 
     NSString *accessTokan; 


     NSMutableDictionary *fb_dict; 
    } 


- (IBAction)btn_loginwithfacebook:(id)sender; 
{ 

    if (!FBSession.activeSession.isOpen) 
    { 
     // if the session is closed, then we open it here, and establish a handler for state changes 

     [FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES completionHandler:^(FBSession *session,FBSessionState state, NSError *error) 
     { 
      if (error) 
      { 
       UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
       [alertView show]; 
      } 
      else if(session.isOpen) 
      { 
       [self btn_loginwithfacebook:sender]; 
      } 

     }]; 

     return; 
    } 


    [FBRequestConnection startWithGraphPath:@"me" parameters:[NSDictionary dictionaryWithObject:@"picture,id,birthday,email,name,gender,username" forKey:@"fields"] HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) 
    { 
     if (!error) 
     { 
      if ([result isKindOfClass:[NSDictionary class]]) 
      { 
       //NSDictionary *dictionary; 
       if([result objectForKey:@"data"]) 
        dictionary = (NSDictionary *)[(NSArray *)[result objectForKey:@"data"] objectAtIndex:0]; 
       else 
        dictionary = (NSDictionary *)result; 
       //NSLog(@"dictionary : %@",dictionary); 



       user_email = [dictionary objectForKey:@"email"]; 
       [dictionary retain]; 
       //NSLog(@"%@",user_email);// 
      } 
     } 
    }]; 
    accessTokan = [[[FBSession activeSession] accessTokenData] accessToken]; 
    //NSLog(@"%@",accessTokan); 

    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; 
    [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@",accessTokan]]]; 
    [request setHTTPMethod:@"GET"]; 
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; 
    NSError *error; 
    NSURLResponse *response; 
    NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; 
    NSString *str=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding]; 

    //NSLog(@"%@",str); 
    fb_dict = [str JSONValue]; 
    [str release];} 

에 대한 FacebookAppID : 370546396320150 개 URL 유형 항목 0 URL 구성표는 iOS6 항목 0 :: fb370546396320150