Skip to content

Commit b28a493

Browse files
refactored braze credentials to create braze.xml for android
1 parent 29c1482 commit b28a493

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

app-template/config-template.xml

-4
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@
173173
</platform>
174174

175175
<platform name="android">
176-
<preference name="com.appboy.api_key" value="ANDROID_BRAZE_API_KEY_REPLACE_ME" />
177-
<preference name="com.appboy.android_api_endpoint" value="ANDROID_BRAZE_API_ENDPOINT_REPLACE_ME" />
178-
<preference name="com.appboy.android_fcm_sender_id" value="ANDROID_BRAZE_FCM_SENDER_ID_REPLACE_ME" />
179-
<preference name="com.appboy.firebase_cloud_messaging_registration_enabled" value="true" />
180176
<hook src="copy-build-extras-gradle.js" type="before_build" />
181177
<preference name="android-manifest/application/@android:allowBackup" value="false" />
182178

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"start": "npm run ionic:serve",
4242
"clean": "rm -rf platforms && rm -rf plugins && rm -f config.xml",
4343
"prepare:copay": "npm run clean && npm run apply:copay && ionic cordova platform add ios; ionic cordova platform add android && npm run fix:fcm",
44-
"prepare:bitpay": "npm run clean && npm run apply:bitpay && ionic cordova platform add ios; ionic cordova platform add android && npm run fix:fcm && npm run fix:iab",
44+
"prepare:bitpay": "npm run clean && npm run apply:bitpay && ionic cordova platform add ios; ionic cordova platform add android && npm run fix:fcm && npm run fix:iab && npm run moveBrazeXML",
4545
"clean-all": "git clean -dfx",
4646
"lint": "ionic-app-scripts lint",
4747
"ionic:build": "ionic-app-scripts build",
@@ -98,7 +98,8 @@
9898
"sign:bitpay-linux": "gpg -u 1112CFA1 --output dist/BitPay-linux.zip.sig --detach-sig dist/BitPay-linux.zip",
9999
"sign:bitpay-windows": "gpg -u 1112CFA1 --output dist/BitPay.exe.sig --detach-sig dist/BitPay.exe",
100100
"verify:bitpay-desktop": "gpg --verify dist/BitPay-linux.zip.sig dist/BitPay-linux.zip; gpg --verify dist/BitPay.exe.sig dist/BitPay.exe; gpg --verify dist/BitPay.dmg.sig dist/BitPay.dmg",
101-
"setBrazeCredentials": "node utils/braze-config.js"
101+
"setBrazeCredentials": "node utils/braze-config.js",
102+
"moveBrazeXML": "sh ./utils/braze.sh"
102103
},
103104
"dependencies": {
104105
"@angular/animations": "5.2.11",

utils/braze-config.js

+20-21
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,33 @@ readline.question('Which platform? (ios or android): ', entry => {
1313
readline.close();
1414
return;
1515
}
16-
1716
readline.question('Enter Braze key: ', key => {
1817
readline.question('Enter Braze endpoint: ', endpoint => {
19-
20-
const complete = () => {
21-
fs.writeFileSync(file, content);
22-
console.log(`Braze config successfully updated for ${platform}`);
23-
readline.close();
24-
};
2518
const platform = entry.toUpperCase();
26-
27-
content = content.replace(`${platform}_BRAZE_API_KEY_REPLACE_ME`, key);
28-
29-
content = content.replace(
30-
`${platform}_BRAZE_API_ENDPOINT_REPLACE_ME`,
31-
endpoint
32-
);
33-
3419
if (platform === 'ANDROID') {
3520
readline.question('Enter fcm senderId: ', senderId => {
36-
content = content.replace(
37-
`ANDROID_BRAZE_FCM_SENDER_ID_REPLACE_ME`,
38-
`str_${senderId}`
39-
);
40-
complete();
21+
const brazeXML =
22+
`<?xml version="1.0" encoding="utf-8"?>
23+
<resources>
24+
<string name="com_appboy_api_key">${key}</string>
25+
<string name="com_appboy_custom_endpoint">${endpoint}</string>
26+
<bool name="com_appboy_firebase_cloud_messaging_registration_enabled">true</bool>
27+
<bool name="com_appboy_handle_push_deep_links_automatically">true</bool>
28+
<string name="com_appboy_firebase_cloud_messaging_sender_id">${senderId}</string>
29+
</resources>`;
30+
fs.writeFileSync(`${__dirname}/../app-template/braze.xml`, brazeXML);
31+
console.log('Braze XML successfully created');
32+
readline.close();
4133
});
4234
} else {
43-
complete();
35+
content = content.replace(`${platform}_BRAZE_API_KEY_REPLACE_ME`, key);
36+
content = content.replace(
37+
`${platform}_BRAZE_API_ENDPOINT_REPLACE_ME`,
38+
endpoint
39+
);
40+
fs.writeFileSync(file, content);
41+
console.log(`Braze config successfully updated for ${platform}`);
42+
readline.close();
4443
}
4544
});
4645
});

utils/braze.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
if [ -f ./app-template/braze.xml ]
3+
then
4+
cp ./app-template/braze.xml ./platforms/android/app/src/main/res/values/
5+
echo "BrazeXML successfully moved to platforms src"
6+
else
7+
echo "BrazeXML does not exists"
8+
fi

0 commit comments

Comments
 (0)