FBSDKAppInvite回调不是进入ios

时间:2015-07-30 06:44:11

标签: ios objective-c facebook

我是IOS的初学者,想通过facebook邀请朋友使用我的应用程序。我使用了facebook(4.0)的新框架,我发现对于邀请我需要使用FBSDKAppInvite。

我在“App Links Hosting API快速入门”中设置了深层链接

我使用以下代码进行申请邀请

#pragma mark
#pragma mark - Share via facebbok
- (IBAction)btnShare:(id)sender
{

    FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init];
      content.appLinkURL = [NSURL URLWithString:@"https://fb.me/863075563772717"];
    //optionally set previewImageURL


    // present the dialog. Assumes self implements protocol `FBSDKAppInviteDialogDelegate`
    [FBSDKAppInviteDialog showWithContent:content
                                 delegate:self];   // Do any additional setup after loading the view, typically from a nib.
}

-(void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results
{
    NSLog(@"result::%@",results);
}
-(void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error
{
    NSLog(@"error::%@",error);
}

并按以下方法处理回调

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    // Check if the handler knows what to do with this url
    BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];
    if ([parsedUrl appLinkData]) {
        // this is an applink url, handle it here
        NSURL *targetUrl = [parsedUrl targetURL];
        [[[UIAlertView alloc] initWithTitle:@"Received link:"
                                    message:[targetUrl absoluteString]
                                   delegate:nil
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil] show];
    }
    return YES;
}

但是我的 [parsedUrl appLinkData]

我不明白我做错了什么。我还将URLScheme放在Plist中。

任何帮助都可以理解

更新

如果我使用以下方法,那么我在委托方法中获得成功,但邀请不会发送给收件人。

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

    // Check if the handler knows what to do with this url
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}

0 个答案:

没有答案