How to invite friends to my application via facebook iOS SDK and Graph API

后端 未结 8 463
攒了一身酷
攒了一身酷 2021-02-01 17:55

I\'m writing an iPhone application.

I want to give the user the option to invite friends to start using my application via Facebook.

More specifically I want to

8条回答
  •  醉酒成梦
    2021-02-01 18:21

    Make sure your facebook app id is same in both developer page and info in xcode next, enable sandbox mode and must fill canvas url [under app on facebook category] in developer page.

    NSString *facebookID = @"Your friend facebook id";;
        NSMutableDictionary* params =
        [NSMutableDictionary dictionaryWithObject:facebookID forKey:@"to"];
    
        NSString *message = @"SOME_MESSAGE";
        NSString *title = @"TITLE";
    
        [FBWebDialogs presentRequestsDialogModallyWithSession:nil
                      message:message
                    title:title
                    parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                            if (error)
                        {
                        // Case A: Error launching the dialog or sending request.
                            NSLog(@"Error sending request.");
                        }
                        else
                        {
                            if (result == FBWebDialogResultDialogNotCompleted)
                        {
                        // Case B: User clicked the "x" icon
                            NSLog(@"User canceled request.");
                        }
                        else
                        {
                            NSLog(@"Request Sent. %@", params);
                        }
            }}];
    

提交回复
热议问题