使用新的Facebook SDK 3.1和iOS 6,有2种(实际上3种)发布方式.
(似乎新趋势是有更多的选择让它变得更简单?)OMG !!
这是一个:
SLComposeViewController *fbPost = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[fbPost addURL:[NSURL URLWithString:href]];
[self presentViewController:fbPost animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
这是使用原生对话框的另一种方式:
[FBNativeDialogs presentShareDialogModallyFrom:self
initialText: nil
image: nil
url: [NSURL URLWithString:href]
handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
}
else
{
switch (result) {
case FBNativeDialogResultSucceeded:
break;
case FBNativeDialogResultCancelled:
break;
case FBNativeDialogResultError:
break;
}
}
}];
Run Code Online (Sandbox Code Playgroud)
我们开发人员认为这很酷,因为我们为用户提供了一个很好的功能,也因为我们的应用名称出现在帖子中,可以对应用进行一些推广.
有趣的是,最新的实现不允许指定应用程序名称是发布,名称出现在'via'之后.
我尝试过使用SLRequest:
ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *fbType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
(options)[@"ACFacebookAppIdKey"] = kFacebookAppID;
(options)[@"ACFacebookPermissionsKey"] = …Run Code Online (Sandbox Code Playgroud)