[英]Sending facebook App invitation using iOS doesn't show app invite dialog for the first time
我正在处理Facebook App邀请,如果我已经登录到Facebook,则出现“应用程序”对话框没有任何问题,但是如果我没有登录,则没有,但是控件转到具有零结果指令的didCompleteWithResults委托。 请帮助
-(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);
}
我建议按以下方式执行此方法,因为此块方法会发生延迟,此外您还应检查响应令牌而不是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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.