1
votes

I am using Facebook Unity SDK v7.4.0 with FBAndroidSDK/4.8.2 and managed to implement deep link in a unity game for android platform. Clicking on the deep link takes me inside the game. Now I want that when the user enters the game, he has to be rewarded. But the GetAppLink callback does not have target url

    Facebook.Unity.FB.GetAppLink(DeepLinkCallback);

    void DeepLinkCallback(IAppLinkResult result) 
    { 
       if (result != null && !string.IsNullOrEmpty (result.TargetUrl)) 
       {
       }
       else
       {
           Debug.Log("result is null");
       }
    }

I have gone through many links to try solving this. https://developers.facebook.com/docs/unity/reference/current/FB.GetAppLink http://answers.unity3d.com/questions/1134007/how-to-get-facebook-game-request-url.html Deferred deep links always null in android and facebook SDK

Also deep link is enabled in the developer site, also checked if Facebook sdk is initialised properly before getting the callback

2

2 Answers

0
votes

I dont know about the targetUrl but to reward the user you just have to check result.url as mentioned in the FB.GetAppLink documentation.

FB.GetAppLink(DeepLinkCallback);

void DeepLinkCallback(IAppLinkResult result) {
    if(!String.IsNullOrEmpty(result.Url)) {
        var index = (new Uri(result.Url)).Query.IndexOf("request_ids");
        if(index != -1) {
            **// ...have the user interact with the friend who sent the request,
            // perhaps by showing them the gift they were given, taking them
            // to their turn in the game with that friend, etc.**
        }
    }
}

To send custom data through a Facebook app request, you need to add that data — for example details of your gift — in the FB.AppRequest as mentioned in its documentation.

You need to get the last request id from the URL in the deep link call back and then call Facebook API to get your gift data out of it.

FB.API ("/" + recievedRequestId, HttpMethod.GET, CallbackFunction);
0
votes

result.url will be null if you haven't added a scheme in Facebook SDK's unity settings.

com.example.appname is probably what you are looking to add.

enter image description here