@allboatsrise/expo-marketingcloudsdk 0.0.3 → 45.0.0

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.3",
5
+ "version": "45.0.0",
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, { ...props });
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,19 @@ 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
+ import android.util.Log;
67
+ `.trim(),
68
+ anchor: /public class MainApplication/,
69
+ offset: 0,
70
+ tag: '@allboatsrise/expo-marketingcloudsdk(header)',
71
+ comment: '//'
72
+ }).contents;
58
73
  config.modResults.contents = (0, generateCode_1.mergeContents)({
59
74
  src: config.modResults.contents,
60
75
  newSrc: ` MarketingCloudSdk.init(this,
@@ -76,3 +91,21 @@ const withConfigureMainApplication = (config, props) => {
76
91
  return config;
77
92
  });
78
93
  };
94
+ const withNotificationIconFile = (config, props) => {
95
+ return (0, config_plugins_1.withDangerousMod)(config, [
96
+ 'android',
97
+ async (config) => {
98
+ if (!props.iconFile) {
99
+ throw new Error(`Must set iconFile property.`);
100
+ }
101
+ const completeIconPath = path_1.default.resolve(config.modRequest.projectRoot, props.iconFile);
102
+ if (!fs_1.default.existsSync(completeIconPath)) {
103
+ throw new Error(`File not found at ${completeIconPath}`);
104
+ }
105
+ const targetPath = path_1.default.join(config.modRequest.platformProjectRoot, 'app', 'src', 'main', 'res', 'drawable', 'ic_notification.png');
106
+ fs_1.default.copyFileSync(completeIconPath, targetPath);
107
+ return config;
108
+ },
109
+ ]);
110
+ };
111
+ exports.withNotificationIconFile = withNotificationIconFile;
@@ -118,19 +118,25 @@ const withPushConfiguration = (config, props) => {
118
118
  };
119
119
  const withDelegateImplementation = (config, props) => {
120
120
  return (0, config_plugins_1.withAppDelegate)(config, async (config) => {
121
+ config.modResults.contents = (0, generateCode_1.mergeContents)({
122
+ src: config.modResults.contents,
123
+ newSrc: ` [[MarketingCloudSDK sharedInstance] sfmc_setDeviceToken:deviceToken];`,
124
+ anchor: /return \[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\];/,
125
+ offset: 0,
126
+ tag: '@allboatsrise/expo-marketingcloudsdk(user-notification-method-didRegisterForRemoteNotificationsWithDeviceToken)',
127
+ comment: '//'
128
+ }).contents;
129
+ config.modResults.contents = (0, generateCode_1.mergeContents)({
130
+ src: config.modResults.contents,
131
+ newSrc: `os_log_debug(OS_LOG_DEFAULT, "didFailToRegisterForRemoteNotificationsWithError = %@", error);`,
132
+ anchor: /return \[super application:application didFailToRegisterForRemoteNotificationsWithError:error\];/,
133
+ offset: 0,
134
+ tag: '@allboatsrise/expo-marketingcloudsdk(user-notification-method-didFailToRegisterForRemoteNotificationsWithError)',
135
+ comment: '//'
136
+ }).contents;
121
137
  config.modResults.contents = (0, generateCode_1.mergeContents)({
122
138
  src: config.modResults.contents,
123
139
  newSrc: `
124
- - (void)application:(UIApplication *)application
125
- didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
126
- [[MarketingCloudSDK sharedInstance] sfmc_setDeviceToken:deviceToken];
127
- }
128
-
129
- - (void)application:(UIApplication *)application
130
- didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
131
- os_log_debug(OS_LOG_DEFAULT, "didFailToRegisterForRemoteNotificationsWithError = %@", error);
132
- }
133
-
134
140
  // The method will be called on the delegate when the user responded to the notification by opening
135
141
  // the application, dismissing the notification or choosing a UNNotificationAction. The delegate
136
142
  // must be set before the application returns from applicationDidFinishLaunching:.
@@ -152,22 +158,25 @@ const withDelegateImplementation = (config, props) => {
152
158
  NSLog(@"User Info : %@", notification.request.content.userInfo);
153
159
  completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert |
154
160
  UNAuthorizationOptionBadge);
155
- }
156
-
157
- // This method is REQUIRED for correct functionality of the SDK.
158
- // This method will be called on the delegate when the application receives a silent push
159
- - (void)application:(UIApplication *)application
160
- didReceiveRemoteNotification:(NSDictionary *)userInfo
161
- fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
162
- [[MarketingCloudSDK sharedInstance] sfmc_setNotificationUserInfo:userInfo];
163
-
164
- completionHandler(UIBackgroundFetchResultNewData);
165
161
  }`.trim(),
166
162
  anchor: /-\s*\(BOOL\)application:\(UIApplication\s*\*\)application\s*didFinishLaunchingWithOptions/,
167
163
  offset: -1,
168
164
  tag: '@allboatsrise/expo-marketingcloudsdk(user-notification-methods)',
169
165
  comment: '//'
170
166
  }).contents;
167
+ config.modResults.contents = (0, generateCode_1.mergeContents)({
168
+ src: config.modResults.contents,
169
+ newSrc: `
170
+ // This method is REQUIRED for correct functionality of the SDK.
171
+ // This method will be called on the delegate when the application receives a silent push
172
+ [[MarketingCloudSDK sharedInstance] sfmc_setNotificationUserInfo:userInfo];
173
+ completionHandler(UIBackgroundFetchResultNewData);
174
+ `,
175
+ anchor: /return \[super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler\]/,
176
+ offset: 0,
177
+ tag: '@allboatsrise/expo-marketingcloudsdk(user-notification-method-didReceiveRemoteNotification)',
178
+ comment: '//'
179
+ }).contents;
171
180
  return config;
172
181
  });
173
182
  };
@@ -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'.