페이스 북 코드가 잘못 되었기 때문에 나는 그것을 어떻게 할 방법을 찾았는지 설명하고 전체 코드를 게시합니다.
오픈 그래프 아이디어를 잊어 버렸고 버튼으로 트리거 된 간단한 조건부 문자열을 게시하기로 결정했습니다. 거기에서 나는 페이스 북의 코드를 here에서 사용했고, 단지 "Share Dialog"가 완전히 작동하지 않기 때문에 폴백을 사용했다.
-(IBAction)facebookShare:(id)sender {
//Set Variables
int scoreText
int highScoreText
//Format the description
NSString *description;
NSString *t1 = @"I just got a score of ";
NSString *t1Alt = @"I just got a new high score of ";
NSString *t2 = @"! Can you beat it?";
if (self.newHigh == NO){
description = [NSString stringWithFormat:@"%@%@%@",t1,scoreText,t2];
} else if (self.newHigh == YES){
description = [NSString stringWithFormat:@"%@%@%@",t1Alt,highScoreText,t2];
}
// Put together the dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Edit Me", @"name",
@"Edit Me", @"caption",
description, @"description",
@"http://Edit.Me.Too/", @"link",
@"http://And.Me.Too/", @"picture",
nil];
/* * * * * * * * * * * DO NOT EDIT BELOW THIS LINE * * * * * * * * * * * *
* *
* *
* From here on, this shows share screen *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"Error publishing story: %@", error.description);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
NSLog(@"result %@", result);
}
}
}
}];
}
: 거기에서
난 그냥 여기
[NSString stringWithFormat:%@%@%@,string1,self.score,string2];
가 (다른 사람에 대한 일반적인 것으로 수정) 샘플 코드 사용