Skip to content

Commit

Permalink
Merge pull request #303 from BranchMetrics/feat-multiple-link-domains
Browse files Browse the repository at this point in the history
Feat multiple link domains
  • Loading branch information
ethanneff authored Mar 21, 2017
2 parents 99fc717 + 25b5d72 commit 5f0d00f
Show file tree
Hide file tree
Showing 12 changed files with 3,044 additions and 38 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ node_modules
cordova-ionic-phonegap-branch-deep-linking.iml
local.properties
out/
src/cordova-ionic-phonegap-branch-deep-linking.iml
npm-debug.log*
*.map
yarn.lock
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ testbed/
plugin.template.xml
gulpfile.js
CONTRIBUTING.md
travis_after_all.py
travis_after_all.py
yarn.lock
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
```sh
git clone git@github.com:BranchMetrics/cordova-ionic-phonegap-branch-deep-linking.git;
cd cordova-ionic-phonegap-branch-deep-linking;
rm -rf node_modules;
yarn install --save-dev;
yarn install
```

## Develop
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@
<branch-config>
<branch-key value="key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3" />
<uri-scheme value="branchcordova" />
<link-domain value="cordova.app.link" />
<link-domain value="yourcustomdomain.com" />
<link-domain value="cordova.app.link" /> <!-- optional previous link domain -->
<link-domain value="bnc.lt" /> <!-- optional previous link domain -->
<ios-team-release value="PW4Q8885U7" />
<ios-team-debug value="FG35JLLMXX" /> <!-- optional -->
<android-prefix value="/WSuf" /> <!-- optional (for bnc.lt) -->
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "branch-cordova-sdk",
"description": "Branch Metrics Cordova SDK",
"main": "www/branch.js",
"version": "2.5.10",
"version": "2.5.11",
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
"repository": {
"type": "git",
Expand Down Expand Up @@ -60,4 +60,4 @@
"validate-commit-msg": "^2.11.2",
"xml2js": "^0.4.17"
}
}
}
2 changes: 1 addition & 1 deletion plugin.template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="branch-cordova-sdk"
version="2.5.10">
version="2.5.11">

<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->

Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="branch-cordova-sdk"
version="2.5.10">
version="2.5.11">

<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->

Expand Down
40 changes: 22 additions & 18 deletions src/scripts/android/updateAndroidManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,29 @@
// determine the Branch link domain <data> to append to the App Link intent filter
function getAppLinkIntentFilterData (preferences) {
var intentFilterData = []

if (preferences.linkDomain.indexOf('app.link') !== -1) {
// app.link needs an additional -alternate link domain
var first = preferences.linkDomain.split('.')[0]
var rest = preferences.linkDomain.split('.').slice(2).join('.')
var alternate = first + '-alternate' + '.' + rest

intentFilterData.push(getAppLinkIntentFilterDictionary(preferences.linkDomain))
intentFilterData.push(getAppLinkIntentFilterDictionary(alternate))
} else if (preferences.linkDomain.indexOf('bnc.lt') !== -1) {
// bnc.lt
if (preferences.androidPrefix == null) {
throw new Error('BRANCH SDK: Missing "android-prefix" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
var linkDomains = preferences.linkDomain

for (var i = 0; i < linkDomains.length; i++) {
var linkDomain = linkDomains[i]

// app.link link domains need -alternate associated domains as well (for Deep Views)
if (linkDomain.indexOf('app.link') !== -1) {
var first = linkDomain.split('.')[0]
var rest = linkDomain.split('.').slice(2).join('.')
var alternate = first + '-alternate' + '.' + rest

intentFilterData.push(getAppLinkIntentFilterDictionary(linkDomain))
intentFilterData.push(getAppLinkIntentFilterDictionary(alternate))
} else if (linkDomain.indexOf('bnc.lt') !== -1) {
// bnc.lt
if (preferences.androidPrefix == null) {
throw new Error('BRANCH SDK: Missing "android-prefix" in <branch-config> in your config.xml. Docs https://goo.gl/GijGKP')
}
intentFilterData.push(getAppLinkIntentFilterDictionary(linkDomain, preferences.androidPrefix))
} else {
// custom
intentFilterData.push(getAppLinkIntentFilterDictionary(linkDomain))
}

intentFilterData.push(getAppLinkIntentFilterDictionary(preferences.linkDomain, preferences.androidPrefix))
} else {
// custom
intentFilterData.push(getAppLinkIntentFilterDictionary(preferences.linkDomain))
}

return intentFilterData
Expand Down
23 changes: 14 additions & 9 deletions src/scripts/ios/updateAssociatedDomains.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,23 @@
function updateAssociatedDomains (preferences) {
var domainList = []
var prefix = 'applinks:'
var linkDomains = preferences.linkDomain

// add link domain to associated domain
domainList.push(prefix + preferences.linkDomain)
for (var i = 0; i < linkDomains.length; i++) {
var linkDomain = linkDomains[i]

// app.link link domains need -alternate associated domains as well (for Deep Views)
if (preferences.linkDomain.indexOf('app.link') !== -1) {
var first = preferences.linkDomain.split('.')[0]
var second = preferences.linkDomain.split('.')[1]
var rest = preferences.linkDomain.split('.').slice(2).join('.')
var alternate = first + '-alternate'
// add link domain to associated domain
domainList.push(prefix + linkDomain)

domainList.push(prefix + alternate + '.' + second + '.' + rest)
// app.link link domains need -alternate associated domains as well (for Deep Views)
if (linkDomain.indexOf('app.link') !== -1) {
var first = linkDomain.split('.')[0]
var second = linkDomain.split('.')[1]
var rest = linkDomain.split('.').slice(2).join('.')
var alternate = first + '-alternate'

domainList.push(prefix + alternate + '.' + second + '.' + rest)
}
}

return domainList
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/ios/updatePlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

// override
obj.branch_key = preferences.branchKey
obj.branch_app_domain = preferences.linkDomain
obj.branch_app_domain = preferences.linkDomain[0]

return obj
}
Expand Down
14 changes: 13 additions & 1 deletion src/scripts/npm/processConfigXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'projectRoot': getProjectRoot(context),
'projectName': getProjectName(configXml),
'branchKey': getBranchValue(branchXml, 'branch-key'),
'linkDomain': getBranchValue(branchXml, 'link-domain'),
'linkDomain': getBranchLinkDomains(branchXml, 'link-domain'),
'uriScheme': getBranchValue(branchXml, 'uri-scheme'),
'iosBundleId': getBundleId(configXml, 'ios'),
'iosProjectModule': getProjectModule(context),
Expand All @@ -77,6 +77,18 @@
return (branchXml.hasOwnProperty(key)) ? branchXml[key][0]['$']['value'] : null
}

// read branch value from <branch-config> for multiple <link-domain>
function getBranchLinkDomains (branchXml, key) {
var output = []
if (branchXml.hasOwnProperty(key)) {
for (var i = 0; i < branchXml[key].length; i++) {
var item = branchXml[key][i]
output.push(item['$']['value'])
}
}
return output
}

// read bundle id from config.xml (optional values override widget-id)
function getBundleId (configXml, platform) {
var output = null
Expand Down
Loading

0 comments on commit 5f0d00f

Please sign in to comment.