Reputation: 386
I'm trying to make use of Branch's deep-linking (particularly deferred deep-linking) capabilities in my Ionic project. The problem is, their docs for Cordova/Ionic are incomplete. After installing their Cordova plugin, my application still does not recognize the Branch provider as described in the documentation. However, I can't for the life of me find any information about a provider name to declare for the Cordova plugin or requiring it in my angular module.
I've tried declaring Branch
, branch
, io.branch.sdk
, and a bunch of other names, not recognized.
Calling any of the Branch functions described in the Branch SDK docs will result in a reference error. I've reached out to their technical support, but their response was essentially that their in-house team is inexperienced in Cordova/Ionic so they'll have to get back to me after consulting with their Ionic contractor, which I really don't have time for. Has anyone gotten this working in Ionic/Cordova?
Upvotes: 0
Views: 1434
Reputation: 3441
First, make sure you are installing npm Branch via branch-cordova-sdk instead of https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git
remove the old if already installed
cordova plugin remove io.branch.sdk
install the correct npm (fill in xxxx)
cordova plugin add branch-cordova-sdk --variable BRANCH_KEY=xxxx --variable URI_SCHEME=xxxx
Second, make sure your Branch init is in the correct location:
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
...
$ionicPlatform.on('deviceready', function(){
Branch.initSession().then(function (res) {
console.log(res);
alert('Response: ' + JSON.stringify(res));
}).catch(function (err) {
console.error(err);
alert('Error: ' + JSON.stringify(err));
});
});
});
})
Finally, you can test if it is working by:
1) Running the app after installing the Branch plugin
2) Safari -> Develop -> APP_NAME -> index.html -> Console -> "Branch" Overall,
1) Make sure you are always testing Branch on a device (not a simulator or browser)
2) Make sure you are npm installing branch-cordova-sdk instead of the github link
3) You can find the SDK documentation here: https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking
Hope this helps!
Upvotes: 1
Reputation: 13613
Alex from Branch here: my apologies for the delay. We're currently working on a major update to the Cordova/Ionic documentation, because we've had similar feedback on several occasions recently.
In the meantime, feel free to post an issue on our SDK GitHub repo. Our contractors monitor this, so you will likely get a more timely response there.
Upvotes: 0