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 :)