deep linking - Integrating Branch.io in Ionic App -
i trying send app's link form website token in link :
branch.link({ stage: 'new user', data: { token: 543322 }}, function(err, link) { console.log(err, link); });
then when app installed user after clicking on link, want token register user. tried reading branch.io docs , implementing it's not working. can tell me example how make work? code in app controller this
(():void => { 'use strict'; angular .module('xyz') .controller('abc', abc); function abc ( $window ) { let vm = this; $window.branch.setdebug(true); $window.branch.initsession().then(function (res) { console.log(res); alert('response: ' + json.stringify(res)); }).catch(function (err) { console.error(err); alert('error: ' + json.stringify(err)); }); $window.branch.getfirstreferringparams().then(function (res) { // success callback alert('res'+res); }).catch(function (err) { // error callback alert('err'+err); }); $window.branch.getlatestreferringparams().then(function (res) { // success callback alert(res); }).catch(function (err) { // error callback alert(err); }); function deeplinkhandler (data) { alert('data initsession: ' + data.data); } $window.deeplinkhandler = deeplinkhandler; })();
alex branch here: there 3 steps process:
1. create link
you're doing code provided in question.
2. integrate branch sdk app
the docs page covering steps here: https://dev.branch.io/getting-started/sdk-integration-guide/guide/cordova/
3. watch incoming link, , route it
the docs page covering need here: https://dev.branch.io/getting-started/deep-link-routing/advanced/cordova/
basically, function this:
function deeplinkhandler(data) { console.log("received data: " + json.stringify(data)); (key in data) { if ((key != "type" && key != "source" && key != "bubbles" && key != "cancelbubble") && data[key] != null) { console.log(key + ": " + data["key"]); } } if (data["token"]) { // load view register user based on token } else { // load normal view } }
Comments
Post a Comment