2

I am using facebook SDK , and when I am trying to invite friend via facbook by using fb invite deep linking.

NSDictionary * getParam = @{
                            @"access_token":accessToken,
                            @"fields":@"canonical_url",
                            @"pretty":@(YES),
                            };
NSString * getCanoicalURL = [NSString stringWithFormat:@"%@/%@",FB_CANONICAL_API, fbAPILinkID];
[self GET:getCanoicalURL parameters:getParam success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject)
 {
     NSError *error;
     FacebookLink * getResult = [MTLJSONAdapter modelOfClass:[FacebookLink class] fromJSONDictionary:responseObject error:&error];
     if (error)
     {
         handler(nil,error);
     }
     else
     {
         handler(getResult.canonicalUrl,nil);
     }
 } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)
 {
     handler(nil,error);
 }];

The below is my invite friend method it show successfully :

-(void)inviteFriend:(NSString*)canonicalUrl
{
        FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init];
        content.appLinkURL =[NSURL URLWithString:canonicalUrl];

        [FBSDKAppInviteDialog showFromViewController:self withContent:content delegate:self];
}

But when I try to fetch for defer deep link it always null:

FBSDKAppLinkUtility fetchDeferredAppLink:^(NSURL *url, NSError *error)
         {
             NSLog(@"fetch defer app link :%@",url);
             if (error) {
                 NSLog(@"Received error while fetching deferred app link %@", error);
             }
             if (url) {
                 [[UIApplication sharedApplication] openURL:url];
             }
         }];

2 Answers2

1

Be sure that your iPhone's Limit Ad Tracking setting is off, at Settings -> Privacy -> Advertising

OFK
  • 41
  • 3
0

Get parts of a NSURL in objective-c

This will be ur exact reference and answer not so manual coding as above.

Community
  • 1
  • 1
codelover
  • 1,113
  • 10
  • 28
  • I use facebook deeplink to generate referal like this. https://developers.facebook.com/docs/applinks/ios . And it's not problem with exact URL but the problem is when I am trying to fetch defer link from facebook server the url is always null. We are trying to fetch defer app link when user click on install button after we invited user via facebook. – Mcom Luckydraw Mar 06 '16 at 17:25