Deep linking, REST authentication with Google/PlayFab

I’m trying to implement PlayFab into my game. I want to be able to register/login with Google (I have registration with email working OK). As far as I can tell, the way to do this with the PlayFab REST interface (via the PlayFabLuaSDK) is for me to have a web page which invites the player to sign in via Google, then authenticates with PlayFab. This bit works OK - I found a PlayFab example here which gave me a useful index.html file.

I can get Defold to open this web page OK with sys.open_url(MY_URL) and PlayFab reponds fine, the response being picked up in the index.html here…

      // Handles response from PlayFab
      function onPlayFabResponse(response, error) {
          if (response) {
              logLine("Response: " + JSON.stringify(response));
              // do something here to get the info back to Defold??
               }
          if (error)
              logLine("Error: " + JSON.stringify(error));
      }

and I assume in Defold I need to be doing something like:
playfab.LoginWithGoogleAccount.flow(request, onSuccessGoogleLogin, onErrorGoogleLogin)
or maybe just picking up the Entity Token details etc from the PlayFab response.

But I’m not at all clear how I actually get that information into Defold. I assume I need to do some kind of deep linking, some function in the javascript to open my app via a URL, but I can’t find any examples or documentation on how this is actually done.

I have added an intent filter to my AndroidManifest as below:

        <activity android:name="com.dynamo.android.DefoldActivity"
                  android:configChanges="orientation|screenSize|keyboardHidden">
            <!-- Intent filter to handle custom URL scheme -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="com.mycompany.mygame"/>
            </intent-filter>
        </activity>

where com.mycompany.mygame matches the package.

That’s about as far as I can work out what to do - I am not clear how I actually get the info which has come back from PlayFab back into Defold.

Are there any examples of this or can anyone advise me how to proceed? I feel like I’m nearly there but am failing to grasp one last step which will hopefully get me there.

Any help very much appreciated, thanks!

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Have made some progress, in that the app is now opening via the web page (I needed to make the redirect happen on a button press not just automatically).

I found the iac extension - is that what I need for my game to respond to being reopened?

I’ve not had any luck with it… I added this to my main.init:

local function iac_listener(self, payload, type)
	print("IN IAC LISTENER")

end

function init(self)
	msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
	msg.post("#", "show_screen_title")

	print("init main.script")
	iac.set_listener(iac_listener)
end

but the iac_listener function never seems to get called.

Is this what the iac_listener is for? Or am I missing another way to be able to pick up the data I need from PlayFab?

Thanks

this is the relevant bit of the html file that does the authentication and then calls back to the app once PlayFab responds:

      // Handles response from PlayFab
  function onPlayFabResponse(response, error) {
    console.log("onPlayFabResponse called");
    if (response) {
        // ... existing code to process response ...
        var responseData = encodeURIComponent(JSON.stringify(response));
        redirectUrl = "com.MYCOMPANY.MYGAME://auth?response=" + responseData;
        logLine("Response received. Please click the button to return to the app.");
    } else if (error) {
        // ... existing code to process error ...
        var errorData = encodeURIComponent(JSON.stringify(error));
        redirectUrl = "com.MYCOMPANY.MYGAME://auth?error=" + errorData;
        logLine("Error occurred. Please click the button to return to the app.");
    }
}

function redirectToApp() {
    if (redirectUrl) {
        window.location.href = redirectUrl;
    } else {
        alert("No redirect URL available.");
    }
}
.
.
.
.

.... in the HTML:
    <button onclick="redirectToApp();">Return to App</button>

I thought extension-iac was what you would use to make the app open from the webpage (I’m more knowledgeable about iOS than Android, and seeing extension-iac’s info.plist adding the CFBundleURLSchemes key makes me think that).

So, if you were able to redirect to the app without extension-iac, perhaps your changes to AndroidManifest.xml are interfering with extension-iac’s ? Maybe try reverting to the built-in AndroidManifest.xml.

And then I’d be tempted to try the extension-iac example project in isolation, following the usage instructions in main.gui_script, and then adapt that example to work in the context of your webpage,.