2016-05-07 3 views
0

Facebook Appの招待状に取り組んでいます。既にFacebookにログインしている場合、Appダイアログは問題なく表示されますが、それはコントロールではなく、結果のディクショナリを持つdidCompleteWithResultsデリゲートに行きます。遅延があるので、可能iOSを使用したApp Invitationでは、初めての招待ダイアログは表示されません。

-(IBAction)InviteFBFriends:(id)sender 

{ 
     if (![FBSDKAccessToken currentAccessToken]) 
    { 
     FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];   

     [login logInWithReadPermissions:@[@"public_profile",@"email", @"user_photos"] fromViewController:viewController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 

      if (error) { 

       // Process error 

      } else if (result.isCancelled) { 

       // Handle cancellations 

      } else if([FBSDKAccessToken currentAccessToken]){ 

       [self InviteFBFriends:nil]; 

      } 

     }]; 

     return; 

    } 

    //FOR SENDING INVITATIONS TO FRIENDS 

    FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init]; 

    content.appLinkURL = [NSURL URLWithString:myAppLinkURL]; 



    FBSDKAppInviteDialog *fBSDKAppInviteDialog = [[FBSDKAppInviteDialog alloc] init]; 

    fBSDKAppInviteDialog.delegate = self; 

    fBSDKAppInviteDialog.content = content; 

    [fBSDKAppInviteDialog show]; 

} 



- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results{ 

    NSLog(@"%@",results); 

} 

- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error{ 

    NSLog(@"%@",error); 

} 

答えて

1

場合は助けてください、私はあなたの応答をチェックする必要があります以外に、このブロックの方法で発生したトークンの代わりに、currentAccessToken

-(IBAction)InviteFBFriends:(id)sender { 

    if (![FBSDKAccessToken currentAccessToken]) { 

     FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; 

     [login logInWithReadPermissions:@[@"public_profile",@"email", @"user_photos"] fromViewController:viewController handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { 

      if (error) { 

       // Process error 

      } else if (result.isCancelled) { 

       // Handle cancellations 

      } else if(result.token){ 

       [self showInvitationsToFriends]; 

      } 

     }]; 
    } 
} 

- (void)showInvitationsToFriends { 
    //FOR SENDING INVITATIONS TO FRIENDS 

    FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init]; 
    content.appLinkURL = [NSURL URLWithString:myAppLinkURL]; 
    [FBSDKAppInviteDialog showFromViewController:self withContent:content delegate:self]; 
} 
+0

がなかった、以下のように、この方法を実行推薦します作業。コントロールが[fBSDKAppInviteDialog show]に行くので、なぜこれが起こっているのか分かりません。その後、dialog didCompleteWithResultsメソッドが表示されずに呼び出されます。 – user3921894

+0

しかし、ログインしている場合は、ダイアログビューが表示されますか? – Mortgy

+0

ダイアログボタンが表示されるようにログインボタンを2回押す必要がありますか? – Mortgy

関連する問題