react-native-acoustic-mobile-push-location-beta 3.9.10 → 3.9.11

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/postinstall.js +79 -59
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "main": "index.js",
25
25
  "name": "react-native-acoustic-mobile-push-location-beta",
26
26
  "peerDependencies": {
27
- "react-native-acoustic-mobile-push-beta": "3.9.10"
27
+ "react-native-acoustic-mobile-push-beta": "3.9.11"
28
28
  },
29
29
  "repository": {
30
30
  "directory": "plugins/react-native-acoustic-mobile-push-location",
@@ -36,5 +36,5 @@
36
36
  "test": "echo \"Error: no test specified\" && exit 1"
37
37
  },
38
38
  "summary": "react-native ios android mobile push Campaign",
39
- "version": "3.9.10"
39
+ "version": "3.9.11"
40
40
  }
package/postinstall.js CHANGED
@@ -167,82 +167,105 @@ function modifyInfoPlist(mainAppPath) {
167
167
  fs.writeFileSync(infoPath, plist.build(infoPlist), "utf8");
168
168
  }
169
169
 
170
- function updateiOSConfigFile(mainAppPath) {
171
- const configName = 'MceConfig.json';
172
- const configPath = path.join(mainAppPath, configName);
173
- var config = JSON.parse(fs.readFileSync(configPath));
174
-
175
- console.log("Adding location preferences to iOS MceConfig.json file.");
176
- config["Please note, the existince of the location key is not required, if it is not present though, iBeacon and Geofence support will be disabled."] = ""
177
-
178
- if(typeof(config.location) == "undefined") {
179
- config.location = {
180
- "The location autoInitialize flag can be set to false to delay turning on the location services until desired.": "",
181
- "autoInitialize": true,
182
-
183
- "The sync key is only used to customize the iBeacon and Geofence syncing sevice, it is not required for those features": "",
184
- "sync": {
185
- "Location Sync radius is in meters, default 100km": "",
186
- "syncRadius": 100000,
187
-
188
- "Specify how long to wait before syncing again on significant location change in seconds, default 5 minutes": "",
189
- "syncInterval": 300
190
- }
191
- };
192
- }
170
+ function updateiOSConfigFile(projectPath, mainAppPath) {
171
+ const campaignConfigName = 'CampaignConfig.json';
172
+ const appConfigName = 'MceConfig.json';
173
+ const campaignConfigPath = path.join(projectPath, campaignConfigName);
174
+ const appConfigPath = path.join(mainAppPath, appConfigName);
175
+
176
+ let configTemplate = {
177
+ "The location autoInitialize flag can be set to false to delay turning on the location services until desired.": "",
178
+ "autoInitialize": true,
179
+
180
+ "The sync key is only used to customize the iBeacon and Geofence syncing sevice, it is not required for those features": "",
181
+ "sync": {
182
+ "Location Sync radius is in meters, default 100km": "",
183
+ "syncRadius": 100000,
184
+
185
+ "Specify how long to wait before syncing again on significant location change in seconds, default 5 minutes": "",
186
+ "syncInterval": 300
187
+ }
188
+ };
189
+
190
+ var config = JSON.parse(fs.readFileSync(campaignConfigPath));
191
+
192
+ if(typeof(config.iOS.location) == "undefined") {
193
+ console.log("Adding location preferences to iOS CampaignConfig.json file.");
194
+ config.iOS["Please note, the existince of the location key is not required, if it is not present though, iBeacon and Geofence support will be disabled."] = "";
193
195
 
194
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
196
+ config.iOS.location = configTemplate;
197
+
198
+ fs.writeFileSync(campaignConfigPath, JSON.stringify(config, null, 2));
199
+
200
+ console.log("Adding location preferences to Android MceConfig.json file.");
201
+ var appConfig = JSON.parse(fs.readFileSync(appConfigPath));
202
+
203
+ appConfig.location = configTemplate;
204
+ fs.writeFileSync(appConfigPath, JSON.stringify(appConfig, null, 2));
205
+ }
195
206
  }
196
207
 
197
- function updateAndroidConfigFile(installDirectory) {
198
- const configName = 'MceConfig.json';
199
- const configPath = path.join(installDirectory, "android", "app", "src", "main", "assets", configName);
200
- var config = JSON.parse(fs.readFileSync(configPath));
208
+ function updateAndroidConfigFile(projectPath, installDirectory) {
209
+ const campaignConfigName = 'CampaignConfig.json';
210
+ const appConfigName = 'MceConfig.json';
211
+ const campaignConfigPath = path.join(projectPath, campaignConfigName);
212
+ const appConfigPath = path.join(installDirectory, "android", "app", "src", "main", "assets", appConfigName);
201
213
 
202
- console.log("Adding location preferences to Android MceConfig.json file.");
203
- config["Please note, the existince of the location key is not required, if it is not present though, iBeacon and Geofence support will be disabled."] = "";
214
+ let configTemplate = {
215
+ "The location autoInitialize flag can be set to false to delay turning on the location services until desired.": "",
216
+ "autoInitialize": true,
204
217
 
205
- if(typeof(config.location) == "undefined") {
206
- config.location = {
207
- "The location autoInitialize flag can be set to false to delay turning on the location services until desired.": "",
208
- "autoInitialize": true,
218
+ "The sync key is only used to customize the iBeacon and Geofence syncing service, it is not required for those features": "",
219
+ "sync": {
220
+ "Specify how long to wait before syncing again on significant location change in seconds, default 5 minutes":"",
221
+ "syncInterval": 300,
209
222
 
210
- "The sync key is only used to customize the iBeacon and Geofence syncing service, it is not required for those features": "",
211
- "sync": {
212
- "Specify how long to wait before syncing again on significant location change in seconds, default 5 minutes":"",
213
- "syncInterval": 300,
223
+ "Location Sync radius is in meters, default 100km":"",
224
+ "syncRadius": 100000,
214
225
 
215
- "Location Sync radius is in meters, default 100km":"",
216
- "syncRadius": 100000,
226
+ "Specify how long to wait before retrieving a new location from the device, default 5 minutes":"",
227
+ "locationResponsiveness": 300,
217
228
 
218
- "Specify how long to wait before retrieving a new location from the device, default 5 minutes":"",
219
- "locationResponsiveness": 300,
229
+ "Specify the minimum results when looking for locations nearby, default is 1, minimum value is 1":"",
230
+ "minLocationsForSearch": 1,
220
231
 
221
- "Specify the minimum results when looking for locations nearby, default is 1, minimum value is 1":"",
222
- "minLocationsForSearch": 1,
232
+ "Specify the maximum results when looking for locations nearby, default is 20, minimum value is 1":"",
233
+ "maxLocationsForSearch": 20,
223
234
 
224
- "Specify the maximum results when looking for locations nearby, default is 20, minimum value is 1":"",
225
- "maxLocationsForSearch": 20,
235
+ "Specify the location providers that will be used to retrieve the device location. 'gps' - gps location. 'network' - wifi + cellular, default is gps + network":"",
236
+ "providerPreferences": ["gps", "network"]
237
+ }
238
+ };
226
239
 
227
- "Specify the location providers that will be used to retrieve the device location. 'gps' - gps location. 'network' - wifi + cellular, default is gps + network":"",
228
- "providerPreferences": ["gps", "network"]
229
- }
230
- };
240
+ var config = JSON.parse(fs.readFileSync(campaignConfigPath));
241
+
242
+ if(typeof(config.android.location) == "undefined") {
243
+ console.log("Adding location preferences to Android CampaignConfig.json file.");
244
+ config.android["Please note, the existince of the location key is not required, if it is not present though, iBeacon and Geofence support will be disabled."] = "";
245
+
246
+ config.android.location = configTemplate;
247
+ fs.writeFileSync(campaignConfigPath, JSON.stringify(config, null, 2));
248
+
249
+ console.log("Adding location preferences to Android MceConfig.json file.");
250
+ var appConfig = JSON.parse(fs.readFileSync(appConfigPath));
251
+
252
+ appConfig.location = configTemplate;
253
+ fs.writeFileSync(appConfigPath, JSON.stringify(appConfig, null, 2));
231
254
  }
232
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
233
255
  }
234
256
 
235
257
  if(process.env.MCE_RN_NOCONFIG) {
236
- console.log(chalk.yellow.bold("Acoustic Mobile Push Location Plugin installed, but will not be auto configured because MCE_RN_NOCONFIG environment flag detected."));
258
+ console.log(chalk.yellow.bold("Acoustic Campaign Location Plugin installed, but will not be auto configured because MCE_RN_NOCONFIG environment flag detected."));
237
259
  return;
238
260
  }
239
261
 
240
- console.log(chalk.green.bold("Setting up Acoustic Mobile Push Location Plugin"));
262
+ console.log(chalk.green.bold("Setting up Acoustic Campaign Location Plugin"));
263
+ const projectPath = process.cwd();
241
264
  const installDirectory = findInstallDirectory();
242
265
  const mainAppPath = findMainPath(installDirectory);
243
266
  modifyInfoPlist(mainAppPath);
244
- updateiOSConfigFile(mainAppPath);
245
- updateAndroidConfigFile(installDirectory);
267
+ updateiOSConfigFile(projectPath, mainAppPath);
268
+ updateAndroidConfigFile(projectPath, installDirectory);
246
269
  modifyManifest(installDirectory);
247
270
 
248
271
  console.log(chalk.green("Installation Complete!"));
@@ -252,7 +275,4 @@ console.log(chalk.blue('For react-native 0.59 and lower link the plugin with:'))
252
275
  console.log('react-native link react-native-acoustic-mobile-push-location\n');
253
276
 
254
277
  console.log(chalk.blue('iOS Support:'));
255
- console.log("Please replace the placeholder location usage descriptions in info.plist in the NSLocationWhenInUseUsageDescription, NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription keys.\n");
256
-
257
- console.log(chalk.blue('Android Support:'));
258
- console.log("Note, this version of the plugin only supports AndroidX on React Native 0.60 and higher");
278
+ console.log("Please replace the placeholder location usage descriptions in info.plist in the NSLocationWhenInUseUsageDescription, NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription keys.\n");