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.
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.
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/
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
来源:https://stackoverflow.com/questions/32044509/error-in-sending-app-invitation-in-ios-to-facebook-friends