NOTE: 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" />
<data android:scheme="ctmodelhouse" android:host="canvas" />
/* This must be changed to identify your respective URL scheme */
</intent-filter>
</activity>
Client Side Code:
if (isMobile.Android()) {
var method = 'iframe';
var fallbackFunction = function() {
if (method != 'intent')
/* Linked to CandyCrush App since the Canvas app is not yet deployed in Google Play Store */
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";
/* This must be changed to identify your respective URL scheme */
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);
//setContentView(R.layout.activity_deeplink);
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.
General
Content
Integrations