Question

Hi I would like to know of a Cordova / Phonegap plugin or way to expose and handle deep-links in my Sencha Touch / Cordova App

So far I am able to deep-link into other applications lets say open Google Play to a specific app detail page.

Using this plugin https://github.com/code4jhon/org.apache.cordova.startapp

So what I would like to do is enable other applications to open specific views or functionalities in my application. I would like to support Android and IOS.

So bottom line is there a Cordova plugin to expose Activities for Android and their counterparts on IOS ?

Or how to achieve this?

Looked into Cordova docs but didn't find anything... any help, doc link would be very much appreciated.

Was it helpful?

Solution

You can try https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin

It worked perfectly for me.

remember to clean/build after installation

You can handle variable implementing handleOpenURL

function handleOpenURL(url) {
  console.log("received url: " + url);
}

OTHER TIPS

There's a new plugin that handles Universal Links for both Android and iOS: https://github.com/nordnet/cordova-universal-links-plugin

I was able to accomplish this using Branch Metrics. They are a new startup and super fantastic.

Check out their cordova plugin docs for deep links here:

https://github.com/BranchMetrics/Branch-PhoneGap-Cordova-SDK#initialize-sdk-and-register-deep-link-routing-function

I recommend reading all their docs to get a feel of what to do. However, with Ionicframework and AngularJS, I built a service you could use in your application:

https://gist.github.com/sean-hill/627fa40f96577baae378

After building your project with Branch's plugin, follow these steps for iOS and Android configuration.

iOS

Add this to your .plist file:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>yourappname</string>
        </array>
    </dict>
</array>

Then cordova build ios; cordova emulate ios. To check if it is working, open your emulator, go to Safari and type in yourappname:// and see if it redirects to your app.

Android

Add this to your AndroidManifest.xml file after building android:

<intent-filter>
    <data android:scheme="yourappname" android:host="open" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

Add this to your config.xml file:

<preference name="AndroidLaunchMode" value="singleTask" />

Then build again and you should be on your way to great deep linking success!

As per @Deminetix request, this is how I close the Branch session.

document.addEventListener("pause", function(){
    var branch = window.Branch;
    branch.closeSession();  
}, false);

Have fun coding :)

I don't think we can use cordova plugins for this. Whole cordova & plugins are meant to establish & execute communication between webpage & native code within the application.

In your case you are trying to allow other apps to have deep links within your app. This could be only done by intent-filter in android & custom-app-url in ios.

appurl.org has some pretty nice step-by-step tutorial on handling custom urls. Have a look at following links

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top