【发布时间】:2015-10-01 14:56:59
【问题描述】:
当我尝试实现 FBSDKShareDialog 以通过我的应用程序执行 facebook 共享时遇到了一些麻烦。如果安装了官方 fb 应用程序,它会显示空白对话框(用户允许在其中键入一些文本等)。如果用户没有 fb 应用程序,它会显示正确的信息,但 FBSDKSharingDelegate 方法不起作用。 (即使用户有FB应用程序也不起作用)
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
NSLog(@"complete");
}
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
NSLog(@"did cancel");
}
- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
NSLog(@"%@", error);
}
即使我通过 FB 应用程序取消或分享,它也不会被调用。 我的代码是:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = _place.title;
content.imageURL = [NSURL URLWithString:_place.logoUrl];
content.contentDescription = _place.info;
[FBSDKShareDialog showFromViewController:_viewController withContent:content delegate:self];
我在@interface 声明中有一个代表。
@interface FacebookHandler () < FBSDKSharingDelegate >
@end
我的应用代理有
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return [[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
我哪里错了?通过FBSDKShareLinkContent 发布一些图片和标题是否是个好主意。提前致谢。
【问题讨论】:
标签: ios objective-c facebook facebook-graph-api