1

My info.plist

enter image description here

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

//optionally set previewImageURL

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

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


//FBSDKAppInviteDialog delegate

-(void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results
{

    NSLog(@"%@",results);
}

-(void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error
{

    NSLog(@"%@",error);
}
vien vu
  • 4,277
  • 2
  • 17
  • 30
Harshal Valanda
  • 5,331
  • 26
  • 63

1 Answers1

0

The applink is not your fb link which is your server php script link like,

"http://ipaddress/folder/sample.php"

Code:

 FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init];
content.appLinkURL = [NSURL URLWithString:@"http://ipaddress/folder/sample.php"];
//optionally set previewImageURL
content.appInvitePreviewImageURL = [NSURL URLWithString:@"http://ipaddress/folder/image.jpg"];

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

Explanation:

1. appLinkURL- I already told this is the script from your server. appInvitePreviewImageURL - You can call the image from same server also.

The appLinkURL contains (In sample.php) Example appname = stackoverflow (here you should add your appname)

Code:

<html>
<head>
    <meta property="al:ios:url" content="stackoverflow://" />
    <meta property="al:ios:app_store_id" content="123456789" />
    <meta property="al:ios:app_name" content="stackoverflow'" />

    <meta property="al:android:url" content="stackoverflow://" />
    <meta property="al:android:app_name" content="stackoverflow" />
    <meta property="al:android:package" content="com.mycompany.couchin" />
    <meta property="al:web:url" content="http://google.com" />
</head>
<body>
    Sample App 
</body>
</html>

Explanation: al:ios:url = This is known as url schema you should add this url schema to your info.plist example below, enter image description here

al:ios:app_store_id: Add appstore id, If you don't have appstore id, please add it example app already have in appstore .

al:ios:app_name: Give you appname here.

2.appInvitePreviewImageURL This image should be display from the link when you are invite your friend.

S. Karthik
  • 618
  • 5
  • 16