Skip to content

Commit d16b4ff

Browse files
authored
Merge pull request #680 from BranchMetrics/staging
Prep update
2 parents 01ae4ec + 556a059 commit d16b4ff

File tree

6 files changed

+86
-4
lines changed

6 files changed

+86
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "branch-cordova-sdk",
33
"description": "Branch Metrics Cordova SDK",
44
"main": "src/index.js",
5-
"version": "4.2.1",
5+
"version": "4.2.2",
66
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
77
"repository": {
88
"type": "git",

plugin.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SOFTWARE.
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="branch-cordova-sdk"
27-
version="4.2.1">
27+
version="4.2.2">
2828

2929
<!-- Description -->
3030
<name>branch-cordova-sdk</name>
@@ -63,7 +63,7 @@ SOFTWARE.
6363
<!-- Manifest configuration is done via a js script. We should move it to this config in the future. -->
6464

6565
<source-file src="src/android/io/branch/BranchSDK.java" target-dir="src/io/branch" />
66-
<framework src="io.branch.sdk.android:library:4.4.0"/>
66+
<framework src="io.branch.sdk.android:library:5.0.7"/>
6767
</platform>
6868

6969
<!-- iOS -->
@@ -87,7 +87,7 @@ SOFTWARE.
8787
<source url="https://github.com/CocoaPods/Specs.git"/>
8888
</config>
8989
<pods>
90-
<pod name="Branch" spec="~> 0.35.0" />
90+
<pod name="Branch" spec="~> 1.39.2" />
9191
</pods>
9292
</podspec>
9393
</platform>

src/scripts/android/updateAssets.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(function() {
2+
// properties
3+
4+
const fs = require("fs");
5+
const path = require("path");
6+
7+
// entry
8+
module.exports = {
9+
addBranchJson: addBranchJson
10+
};
11+
12+
// updates the platforms/ios/*.xcodeproj/project.pbxproj file and adds branch.json file
13+
function addBranchJson(context, preferences) {
14+
if (preferences.branchJson.exists) {
15+
const destination = path.join(
16+
context.opts.projectRoot,
17+
"platforms",
18+
"android",
19+
"app",
20+
"src",
21+
"main",
22+
"assets",
23+
"branch.json"
24+
);
25+
fs.copyFileSync(preferences.branchJson.path, destination);
26+
}
27+
}
28+
})();

src/scripts/hooks/beforePrepare.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
const iosPlist = require("../ios/updatePlist.js");
66
const iosAssociatedDomains = require("../ios/updateAssociatedDomains.js");
77
const iosHeaderPaths = require("../ios/updateHeaderPaths.js");
8+
const iosPbxproj = require("../ios/updatePbxproj.js");
9+
const androidAssets = require("../android/updateAssets.js");
810
const IOS = "ios";
11+
const ANDROID = "android";
912

1013
// entry
1114
module.exports = run;
@@ -16,10 +19,15 @@
1619
const platforms = context.opts.cordova.platforms;
1720

1821
platforms.forEach(platform => {
22+
if (platform === ANDROID) {
23+
androidAssets.addBranchJson(context, preferences);
24+
}
25+
1926
if (platform === IOS) {
2027
iosPlist.addBranchSettings(preferences);
2128
iosAssociatedDomains.addAssociatedDomains(preferences);
2229
iosHeaderPaths.addHeaderPaths();
30+
iosPbxproj.addBranchJson(context, preferences);
2331
}
2432
});
2533
}

src/scripts/ios/updatePbxproj.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(function() {
2+
// properties
3+
4+
const fs = require("fs");
5+
const path = require("path");
6+
7+
// entry
8+
module.exports = {
9+
addBranchJson: addBranchJson
10+
};
11+
12+
// updates the platforms/ios/*.xcodeproj/project.pbxproj file and adds branch.json file
13+
function addBranchJson(context, preferences) {
14+
if (preferences.branchJson.exists && preferences.iosProjectModule.xcode) {
15+
const destination = path.join(
16+
context.opts.projectRoot,
17+
"platforms",
18+
"ios",
19+
"branch.json"
20+
);
21+
fs.copyFileSync(preferences.branchJson.path, destination);
22+
preferences.iosProjectModule.xcode.addResourceFile(destination);
23+
preferences.iosProjectModule.write();
24+
}
25+
}
26+
})();

src/scripts/npm/processConfigXml.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(function() {
22
// properties
33

4+
const fs = require("fs");
45
const path = require("path");
56
const xmlHelper = require("../lib/xmlHelper.js");
67

@@ -57,6 +58,7 @@
5758
return {
5859
projectRoot: getProjectRoot(context),
5960
projectName: getProjectName(configXml),
61+
branchJson: getBranchJson(context),
6062
branchKey: getBranchKey(branchXml, "branch-key-live"),
6163
branchKeyTest: getBranchValue(branchXml, "branch-key-test"),
6264
branchTestMode: getBranchValue(branchXml, "branch-test-mode"),
@@ -96,6 +98,24 @@
9698
return output;
9799
}
98100

101+
// Checks if branch.json exists in projectRoot and returns its path
102+
function getBranchJson(context) {
103+
const pathToBranchJson = path.join(context.opts.projectRoot, "branch.json");
104+
let exists;
105+
106+
try {
107+
fs.existsSync(pathToBranchJson);
108+
exists = true;
109+
} catch(err) {
110+
exists = false;
111+
}
112+
113+
return {
114+
exists: exists,
115+
path: pathToBranchJson
116+
};
117+
}
118+
99119
// read branch value from <branch-config>
100120
function getBranchValue(branchXml, key) {
101121
return branchXml.hasOwnProperty(key) ? branchXml[key][0].$.value : null;

0 commit comments

Comments
 (0)