Mobile Game QR Deep Linking

How to implement deep linking into Pley Connect for the QR Code

The deep link scheme is used for the QR code during account linking with Pley Connect.

The standard Pley Connect deep link has the following structure:
pleyconnect://pley_account_link?link_code_id=1234_abcd

1) Enable deep linking in your mobile game.

2) Initiate Pley Connect with your backend on deep links which contain a pley_account_link code and a linkCodeId.

3) Display the Pley Connect Code UI if linkCodeId is empty or null.

Example C# code to handle the deep linking that Pley Connect requires. This should be implemented into the mobile version of your game.

public static class PleyDeepLinkManager
{
    public static event Action<string> OnPleyConnectDeepLink;

    [RuntimeInitializeOnLoadMethod]
    public static void Init()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        Application.deepLinkActivated += OnDeepLinkActivated;
        if (!string.IsNullOrEmpty(Application.absoluteURL))
        {
            OnDeepLinkActivated(Application.absoluteURL);
        }
#endif
    }

    private static void OnDeepLinkActivated(string url)
    {
        if (string.IsNullOrEmpty(url))
        {
            return;
        }

        var uri = new Uri(url);
        var host = uri.Host;
        if (host != "pley_account_link")
        {
            return;
        }

        var query = HttpUtility.ParseQueryString(uri.Query);
        var linkCodeId = query.Get("link_code_id");
        OnPleyConnectDeepLink?.Invoke(linkCodeId);
    }
}

In this example, if the game is opened with a deep link i.e. gamescheme://pley_account_link then PleyDeepLinkManager.OnPleyConnectDeepLink will be invoked.

The callback will have a string linkCodeId

If the linkCodeId is empty or null then the game should display the Pley Connect UI within the game and show the link code. Read more about requesting a link code from Pley here.

If the linkCodeId has a value, do not show the Pley Connect UI. Instead, send the ID to the game backend which in turn should send it to Pley using the HTTP API connection-kit/get-link-code. Read more about the backend implementation here.

Example of the payload for connection-kit/get-link-code:

{
    "link_code_id": "The linkCodeId from the deep link URL",
    "game_id": "Game id that can be found in the Pley Game Manager",
    "payload": "user id from the game itself"
}

πŸ“˜

Account Linking Successful - and close the game!

Depending on the game backend response show an account link success prompt and close the game. The web-version of the game will automatically start on the player's desktop screen. If the game starts normally, it'll likely confuse the user.

Enabling Deeplinking Schemas on iOS and Android

To deep link at all, you need to enable it in Unity for both your mobile platforms. To enable deep linking in your mobile game, see Unity Documentation here.

For Android.

For iOS.

Pick the same schema on both platforms and input it in the game manager as instructed below.