@allboatsrise/expo-marketingcloudsdk 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@allboatsrise/expo-marketingcloudsdk",
|
|
3
3
|
"author": "All Boats Rise Inc.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.4",
|
|
6
6
|
"description": "Expo module for Salesforce Marketing Cloud SDK",
|
|
7
7
|
"homepage": "https://github.com/allboatsrise/expo-marketingcloudsdk",
|
|
8
8
|
"keywords": [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import { MarketingCloudSdkPluginProps } from '../types';
|
|
3
3
|
export declare const withAndroidConfig: ConfigPlugin<MarketingCloudSdkPluginProps>;
|
|
4
|
+
export declare const withNotificationIconFile: ConfigPlugin<MarketingCloudSdkPluginProps>;
|
|
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.withAndroidConfig = void 0;
|
|
6
|
+
exports.withNotificationIconFile = exports.withAndroidConfig = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
9
10
|
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
10
11
|
const helpers_1 = require("./helpers");
|
|
@@ -15,7 +16,8 @@ const withAndroidConfig = (config, props) => {
|
|
|
15
16
|
// Configure manually via Expo's googleServicesFile property.
|
|
16
17
|
// @see https://stackoverflow.com/a/63109187
|
|
17
18
|
// 3. Configure the SDK in your MainApplication.java class
|
|
18
|
-
config = withConfigureMainApplication(config,
|
|
19
|
+
config = withConfigureMainApplication(config, props);
|
|
20
|
+
config = (0, exports.withNotificationIconFile)(config, props);
|
|
19
21
|
return config;
|
|
20
22
|
};
|
|
21
23
|
exports.withAndroidConfig = withAndroidConfig;
|
|
@@ -55,6 +57,18 @@ const withConfigureMainApplication = (config, props) => {
|
|
|
55
57
|
throw new Error(`Failed to extract sender id from google services file. (path: ${googleServicesFilePath})`);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
60
|
+
config.modResults.contents = (0, generateCode_1.mergeContents)({
|
|
61
|
+
src: config.modResults.contents,
|
|
62
|
+
newSrc: `
|
|
63
|
+
import com.salesforce.marketingcloud.MarketingCloudConfig;
|
|
64
|
+
import com.salesforce.marketingcloud.MarketingCloudSdk;
|
|
65
|
+
import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions;
|
|
66
|
+
`.trim(),
|
|
67
|
+
anchor: /public class MainApplication/,
|
|
68
|
+
offset: 0,
|
|
69
|
+
tag: '@allboatsrise/expo-marketingcloudsdk(header)',
|
|
70
|
+
comment: '//'
|
|
71
|
+
}).contents;
|
|
58
72
|
config.modResults.contents = (0, generateCode_1.mergeContents)({
|
|
59
73
|
src: config.modResults.contents,
|
|
60
74
|
newSrc: ` MarketingCloudSdk.init(this,
|
|
@@ -76,3 +90,21 @@ const withConfigureMainApplication = (config, props) => {
|
|
|
76
90
|
return config;
|
|
77
91
|
});
|
|
78
92
|
};
|
|
93
|
+
const withNotificationIconFile = (config, props) => {
|
|
94
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
95
|
+
'android',
|
|
96
|
+
async (config) => {
|
|
97
|
+
if (!props.iconFile) {
|
|
98
|
+
throw new Error(`Must set iconFile property.`);
|
|
99
|
+
}
|
|
100
|
+
const completeIconPath = path_1.default.resolve(config.modRequest.projectRoot, props.iconFile);
|
|
101
|
+
if (!fs_1.default.existsSync(completeIconPath)) {
|
|
102
|
+
throw new Error(`File not found at ${completeIconPath}`);
|
|
103
|
+
}
|
|
104
|
+
const targetPath = path_1.default.join(config.modRequest.platformProjectRoot, 'app', 'src', 'main', 'res', 'drawable', 'ic_notification.png');
|
|
105
|
+
fs_1.default.copyFileSync(completeIconPath, targetPath);
|
|
106
|
+
return config;
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
109
|
+
};
|
|
110
|
+
exports.withNotificationIconFile = withNotificationIconFile;
|
package/plugin/build/types.d.ts
CHANGED
|
@@ -5,15 +5,17 @@ export declare type MarketingCloudSdkPluginProps = {
|
|
|
5
5
|
accessToken: string;
|
|
6
6
|
/** Marketing Cloud server url */
|
|
7
7
|
serverUrl: string;
|
|
8
|
+
/**
|
|
9
|
+
* (Android only) Local path to an image to use as the icon for push notifications.
|
|
10
|
+
* 96x96 all-white png with transparency. We recommend following
|
|
11
|
+
* [Google’s design guidelines](https://material.io/design/iconography/product-icons.html#design-principles).
|
|
12
|
+
*/
|
|
13
|
+
iconFile?: string;
|
|
8
14
|
/**
|
|
9
15
|
* (Android only) Marketing Cloud FCM sender id. Defaults to `project_info.project_number`
|
|
10
16
|
* defined in `android.googleServicesFile` (google-services.json) if defined.
|
|
11
17
|
*/
|
|
12
18
|
senderId?: string;
|
|
13
|
-
/** Marketing Cloud mid */
|
|
14
|
-
mid?: string;
|
|
15
|
-
inboxEnabled?: boolean;
|
|
16
|
-
locationEnabled?: boolean;
|
|
17
19
|
analyticsEnabled?: boolean;
|
|
18
20
|
/**
|
|
19
21
|
* (iOS only) Environment of the app: either 'development' or 'production'. Defaults to 'development'.
|