0

をログに記録されたとき、私は、ユーザーが以前のFacebookにログインしている、写真を共有するための要求はどっちつかずの状態で失われ、このロジック写真の共有がないユーザーが以前のFacebook

if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) { 
    NSLog(@"has granted!"); 
    [self sharePhotoWithFBSDK:title andImage:image]; //for logged users 
} else { 
    FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init]; 
    [loginManager logInWithPublishPermissions:@[@"publish_actions"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 
    NSLog(@"response logInWithPublishPermissions!!! %@",error); 
     if (!error) { 
      [self sharePhotoWithFBSDK:title andImage:image]; //Non logged users 
     } 
    }]; 
} 

- (void)sharePhotoWithFBSDK:(NSString *)title andImage:(UIImage *)image 
{ 
    FBSDKSharePhoto *sharePhoto = [[FBSDKSharePhoto alloc] init]; 
    sharePhoto.caption = title; 
    sharePhoto.image = image; 

    FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init]; 
    content.photos = @[sharePhoto]; 

    [FBSDKShareAPI shareWithContent:content delegate:self]; 
} 

を持って動作します。ライブラリに入っ私はこの機能_sharePhotoContent yは右このラインFBSDKGraphRequestHandler completionHandler =^(FBSDKGraphRequestConnection * connection, id result, NSError * error) {

私はこれが起こる原因とすることができる合理的なものを考えることができないで死ぬ入る実現しました。

私が知っているのは、セッションを持たないユーザーと同じことをしようとすると(他の人のために)完全に機能します。

答えて

0

問題が見つかりました。

私はメインスレッドで呼び出す必要があるので

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND,0), ^{ 

}); 

に共有ロジックを呼び出した

dispatch_async(dispatch_get_main_queue(), ^{ 
    [self sharePhotoWithFBSDK:title andImage:image]; 
}); 
関連する問題