2

I am trying to send app invitation to facebook friends but getting the following error

app invite error:Error Domain=com.facebook.sdk.core Code=9 "The operation couldn’t be completed. (com.facebook.sdk.core error 9.)"

below is my code

-(IBAction)buttonTapped:(id)sender {
FBSDKAppInviteContent *content = [[FBSDKAppInviteContent alloc] init];
content.appLinkURL = [NSURL URLWithString:@"https://fb.me/115385318808986"];
[FBSDKAppInviteDialog showWithContent:content
                             delegate:self];

}

#pragma mark - FBSDKAppInviteDialogDelegate

- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results
{
  // Intentionally no-op.
}

- (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error
{
NSLog(@"app invite error:%@", error);
NSString *message = error.userInfo[FBSDKErrorLocalizedDescriptionKey] ?:
@"There was a problem sending the invite, please try again later.";
NSString *title = error.userInfo[FBSDKErrorLocalizedTitleKey] ?: @"Oops!";

[[[UIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}

and when I am trying to print the error.userInfo it shows a blank dictionary. Please guide.

iGagan Kumar
  • 406
  • 8
  • 26

3 Answers3

2

For facebook sdk 4.0 and later

at first create an applink.

FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init];
content.appLinkURL = [NSURL     URLWithString:@"https://www.google.com/myapplink"];
//optionally set previewImageURL 

content.appInvitePreviewImageURL = [NSURL URLWithString:@"https://www.google.com/my_invite_image.jpg"];

// present the dialog. Assumes self implements protocol `FBSDKAppInviteDialogDelegate`
[FBSDKAppInviteDialog showWithContent:content
                         delegate:self];

see this link https://developers.facebook.com/docs/app-invites/ios

EDIT:

when you create an app link and you have to provide an url scheme,this url scheme added in your project info plist.after that you add a face book canvas platform in face book developer setting page,and provide a canvas url and save it.

  • I am also doing the same but it is showing the error as shown above – iGagan Kumar Aug 20 '15 at 05:05
  • you have to check app link is create successfully or not.when you create and app link an you have to provide an url scheme,this url scheme added in your project info plist.after that you add a face book canvas platform in face book developer setting page,and provide a canvas url and save it. – Sudipto Mitra Aug 20 '15 at 07:10
2

If you've been looking everywhere like me to figure out why it's not working, turns out Facebook is deprecating App Invites and will completely stop working as of 2/6/2018:

https://developers.facebook.com/blog/post/2017/11/07/changes-developer-offerings/

KBog
  • 3,800
  • 1
  • 25
  • 31
1

I had this error as well. What fixed it was adding

[FBSDKAppEvents activateApp];

in applicationDidBecomeActive:(UIApplication *)application

within the appDelegate. See also https://developers.facebook.com/docs/app-events/ios#appActivation

bicycle
  • 8,315
  • 9
  • 52
  • 72