Deep Links

A deep link is a URL which may be followed to open an app directly to some screen or location. It is entirely up to the game to implement the deep link logic. However, the SDK does include support for Adjust Reattributions. The SDK also includes an API to support for deep links in Unity. Even if your game does not have logic to open to specific areas within your game, it may still be worthwhile to add basic Deep Link support to enalbe reattribution tracking.

To Add Deep Link support to your game:

Adjust Reattribution

To enable adjust re-attribution the Kongregate SDK must be notified when the app is launched using a deep link. Use the KongregateAPI.willOpenUrl() method to do this.

Android

On Android, KongregateAPI.willOpenUrl() must be invoked after the SDK is initialized, though it is not necessary to wait for the READY event. The URI will be cached and passed to Adjust when the SDK is initialized and Analytics collection starts.

// From your activities onCreate method
public void onCreate(Bundle savedInstanceState) {
    if (mAPI == null) {
        mAPI = // initialize kongregate API
    }

    // implement isDeepLink to determine if the intent is a deep link
    if (isDeepLink(intent)) {
        mAPI.willOpenUrl(uri);

        // your logic to handle the deep link
    }
}

Alternatively, if you enable the option KONGREGATE_OPTION_AUTO_PROCESS_DEEP_LINKS the Kongregate SDK will assume all Intent.ACTION_VIEW intents with non-empty data are deep link intents and will automatically notify Adjust when one is used to open an Activity.

iOS

For iOS you should invoke KongregteAPI willOpenUrl: within your Application Delegate openURL: method. On iOS, you do not need to initiaize the Kongregate SDK first. The SDK will notify Adjust when it’s initialized.

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url
 sourceApplication:(NSString *)sourceApplication
        annotation:(id)annotation {
    // implement isDeepLink to determine if the intent is a deep link
    if ([self isDeepLink:url]) {
        [KongregateAPI willOpenUrl:url];

        // your logic to handle the deep link
    }
}

The Android option KONGREGATE_OPTION_AUTO_PROCESS_DEEP_LINKS is not supported on iOS.

Unity

When enabled the Unity plugin automatically notifies Adjust when the app is opened using a deep link.

Unity Deep Links API

Android Setup

The only required step to enable Deep Link support in Unity for Android is to add an android.intent.action.VIEW intent-filter to your UnityPlayerNativeActivity that describes the scheme to be used to open deep links.

<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape">
      <meta-data android:name="android.app.lib_name" android:value="unity" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
      <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="yourgame"/>
      </intent-filter>
    </activity>

The following entry will enable the URL yourgame://someresource/path to open your game, as well as the standord launch icon.

iOS Setup

To enable deep links support in Unity for iOS an URL Type must be added to the plist of your XCode project. The Kongregate SDK includes an Editor tool and post processor plugin to handle this for you. After importing the Kongregate SDK and restarting Unity open Tools -> Kongregate Tools -> Deep Links. Use the editor window to enable deep links and set the URL Scheme.

Deep Link Editor

The above entry will enable the URL yourgame://someresource/path to open your game. To verify the URL Type is added to the generated XCode project look under Info -> URL Types.

Accessing the Open URL

The Kongregate SDK includes an Mobile.GetOpenURL() accessor that may be used to determine the deep link used to open your game. Your game will also received a KONGREGATE_EVENT_OPEN_DEEP_LINK event when the app is openned using a deep link.

It’s important to remember the app may be opened or brought to the foreground using a deep link. You probably want to check getOpenUrl() immediatly after the Kongregate SDK is READY to determine how to navigate the user within your game. You may also want to handle the KONGREGATE_OPTION_AUTO_PROCESS_DEEP_LINKS event to determine if the user should be redirected to a different screen.

void HandleKongregateEvent(string eventName) {
	KongregateAPI kongregate = KongregateAPI.GetAPI();
	switch(eventName) {
    case KongregateAPI.KONGREGATE_EVENT_READY:
    	ParseOpenUrl(kongregate.Mobile.GetOpenURL());
      	break;
    case KongregateAPI.KONGREGATE_EVENT_OPEN_DEEP_LINK:
    	ParseOpenUrl(kongregate.Mobile.GetOpenURL());
        break;
    }
}

void ParseOpenUrl(string url) {
	// implement method to parse the URL and bring the user to
	// the appropriate screen within the game.
}