当我尝试通过我的应用程序实现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
发布一些图片和标题是个好主意。提前谢谢。
答案 0 :(得分:0)
你是从主线程调用[FBSDKShareAPI shareWithContent:content delegate:self]
吗?
答案 1 :(得分:0)
我已经解决了这个问题。问题是我委托了从NSObject继承的文件,该文件不能是委托