Skip to content

Mobile integration

Plarium ID integration example

Development

To develop:

1. Open Unity3d, select the 3D template and create a new project.

2. Select the iOS/Android platform.

3. Import the PlariumPlayUnitySDK.unitypackage file into Unity3d.

4. Create an empty MonoBehaviour script named TestPPAuth.

5. Add the following code to the TestPPAuth file:

using PP;
using UnityEngine;

public class TestPPAuth : MonoBehaviour
{
   public void LoginWithPlarium()
   {
      PlariumPlay.Mobile.Initialize(YOUR_GAME_ID, YOUR_PRIVATE_KEY);
      PlariumPlay.Mobile.Login(OnLoginCompleted, YOUR_REDIRECT_URL);
   }

   private void OnLoginCompleted(LoginResult result)
   {
   }
}

6. Open Unity3d and create a canvas with a button and text.

7. Drag the TestPPAuth file to the created canvas game object. 

8. Set TestPPAuth.LoginWithPlarium as a button click handler.

9. Add the following code to the TestPPAuth.OnLoginCompleted handler:

1
2
3
4
5
private void OnLoginCompleted(LoginResult result)
{
  var text = GameObject.Find("Output").GetComponent<Text>();
  PlariumPlay.Mobile.Me(me => text.text = $"{result}\n\n{me}");
}

10. Activate deep links:

  • Open Project Settings.
  • Navigate to Supported URL schemes.
  • Add oauthtest as custom schema.

11. Use ServerToServer API to associate redirect URL with your app:

POST oauth/redirects
{ "Url":"oauthtest://redirect" }

For Android, you will also need to create AndroidManifest.xml in the Assets/Plugins/Android folder with the following code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
  <application>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" >
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <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="oauthtest" android:host="redirect" />
      </intent-filter>
    </activity>
  </application>
</manifest>

Note

Make sure to replace oauthtest in android:scheme with the schema name and redirect in android:host with the hostname.

Testing

To test the connection between Plarium Play SDK and iOS/Android:

1. Build the XCode project and run it.

Note

Make sure to add the current scene to the list of scenes in the build.

2. Test the connection.

3. Make sure the link opens properly.

Note

In the output, you will get a user token to validate using Configurator API and get a safe userId.