Android Platform

Use Firefox browser to test this functionality using Canvas App in Android platform. Google Chrome does not support Canvas App in Android.

File name: AndroidManifest.xml
File location: ctmodelhouse/ctmodelhouse/platforms/android/AndroidManifest.xml

Native-side Code:

<activity android:name="DeeplinkActivity" android:label="@string/app_name" >
	<intent-filter android:label="@string/app_name">
		<action android:name="android.intent.action.VIEW" />
			<category android:name="android.intent.category.DEFAULT" />
			<category android:name="android.intent.category.BROWSABLE" />
				<!-- The following attribute must be changed to identify your respective URL scheme.-->
				<data android:scheme="ctmodelhouse" android:host="canvas" />
	</intent-filter>
</activity>

Client-side Code:

if (isMobile.Android())
{
	var method = 'iframe';
	var fallbackFunction = function()
	{
		if (method != 'intent')
		/* The following code links to CandyCrush app for representation purpose only.
		*  You must provide the link to your mobile app. */
		window.location = "https://play.google.com/store/apps/details?id=com.king.candycrushsaga";
	};
	var addIFrame = function()
	{
		var iframe = document.createElement("iframe");
		iframe.style.border = "none";
		iframe.style.width = "1px";
		iframe.style.height = "1px";
		/* The following variable must be changed to identify your respective URL scheme 
		* of your application. */
		iframe.src = "ctmodelhouse://canvas";
		document.body.appendChild(iframe);
	};
	
	if (navigator.userAgent.match(/Firefox/))
	{
		window.location = "ctmodelhouse://canvas"; 
		/* Load app via direct deep link. For Android, the URL must have host 
		*  and scheme (i.e. "ctmodelhouse://canvas") while other platforms, 
		*  the scheme "ctmodelhouse://" is enough. */
	} 
	else
	{
		addIFrame();
	}
	setTimeout(fallbackFunction, 750);
}


File name: DeepLinkActivity.java
File location: ctmodelhouse/ctmodelhouse/platforms/android/src/com/intellect/canvas/DeepLinkActivity.java

package com.intellect.CT; 
import android.content.Intent;
import android.os.Bundle;
import org.apache.cordova.Config;
import org.apache.cordova.CordovaActivity;

public class DeeplinkActivity extends CordovaActivity 
{
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		onNewIntent(getIntent());
	}
	protected void onNewIntent(Intent intent)
	{
		String action = intent.getAction();
		String data = intent.getDataString();
		if(Intent.ACTION_VIEW.equals(action) && data != null)
		{
			callHomePage();
		}
	} 
	protected void callHomePage()
	{
		super.init();
		super.loadUrl(Config.getStartUrl());
	}
}


Sample Screen Shots on Android Platform

The following screen shots show sample implementation of deep linking in the ModelHouse mobile app on Android platforms.