react-native-acoustic-mobile-push-location-beta 3.8.17

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 (31) hide show
  1. package/README.md +45 -0
  2. package/android/android-react-native-acoustic-mobile-push-location.iml +254 -0
  3. package/android/build.gradle +45 -0
  4. package/android/react-native-acoustic-mobile-push-location.iml +255 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/java/co/acoustic/mobile/push/plugin/location/RNAcousticMobilePushBroadcastReceiver.java +107 -0
  7. package/android/src/main/java/co/acoustic/mobile/push/plugin/location/RNAcousticMobilePushLocationModule.java +105 -0
  8. package/android/src/main/java/co/acoustic/mobile/push/plugin/location/RNAcousticMobilePushLocationPackage.java +37 -0
  9. package/android/src/main/res/drawable-hdpi/ic_action_back.png +0 -0
  10. package/android/src/main/res/drawable-hdpi/ic_action_forward.png +0 -0
  11. package/android/src/main/res/drawable-mdpi/ic_action_back.png +0 -0
  12. package/android/src/main/res/drawable-mdpi/ic_action_forward.png +0 -0
  13. package/android/src/main/res/drawable-xhdpi/ic_action_back.png +0 -0
  14. package/android/src/main/res/drawable-xhdpi/ic_action_forward.png +0 -0
  15. package/android/src/main/res/drawable-xxhdpi/ic_action_back.png +0 -0
  16. package/android/src/main/res/drawable-xxhdpi/ic_action_forward.png +0 -0
  17. package/android/src/main/res/layout/activity_action_webview.xml +10 -0
  18. package/android/src/main/res/menu/menu_action_webview.xml +19 -0
  19. package/android/src/main/res/values/mce-plugin-displayweb-strings.xml +5 -0
  20. package/ios/RNAcousticMobilePushLocation.h +17 -0
  21. package/ios/RNAcousticMobilePushLocation.m +111 -0
  22. package/ios/RNAcousticMobilePushLocation.xcodeproj/project.pbxproj +278 -0
  23. package/ios/RNAcousticMobilePushLocation.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  24. package/ios/RNAcousticMobilePushLocation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  25. package/ios/RNAcousticMobilePushLocation.xcodeproj/project.xcworkspace/xcuserdata/buchmanj.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  26. package/ios/RNAcousticMobilePushLocation.xcodeproj/xcshareddata/xcschemes/RNAcousticMobilePushLocation.xcscheme +67 -0
  27. package/ios/RNAcousticMobilePushLocation.xcodeproj/xcuserdata/buchmanj.xcuserdatad/xcschemes/xcschememanagement.plist +32 -0
  28. package/ios/RNAcousticMobilePushLocation.xcworkspace/contents.xcworkspacedata +9 -0
  29. package/package.json +39 -0
  30. package/postinstall.js +258 -0
  31. package/react-native-acoustic-mobile-push-location.podspec +23 -0
package/postinstall.js ADDED
@@ -0,0 +1,258 @@
1
+ /*
2
+ * Copyright © 2019, 2023 Acoustic, L.P. All rights reserved.
3
+ *
4
+ * NOTICE: This file contains material that is confidential and proprietary to
5
+ * Acoustic, L.P. and/or other developers. No license is granted under any intellectual or
6
+ * industrial property rights of Acoustic, L.P. except as may be provided in an agreement with
7
+ * Acoustic, L.P. Any unauthorized copying or distribution of content from this file is
8
+ * prohibited.
9
+ */
10
+
11
+ const fs = require('fs');
12
+ const plist = require('plist');
13
+ const path = require('path');
14
+ const xml2js = require('xml2js');
15
+ const chalk = require('chalk');
16
+
17
+ function findInstallDirectory() {
18
+ if(process.env.MCE_RN_DIRECTORY) {
19
+ console.log(chalk.yellow.bold("Using MCE_RN_DIRECTORY override instead of finding the application source directory."))
20
+ return process.env.MCE_RN_DIRECTORY;
21
+ }
22
+
23
+ // Mac
24
+ var currentDirectory = process.argv[ process.argv.length-1 ];
25
+ if(currentDirectory != "$INIT_CWD") {
26
+ return currentDirectory;
27
+ }
28
+
29
+ // Windows
30
+ currentDirectory = process.cwd();
31
+ while(!fs.existsSync(path.join(currentDirectory, "app.json"))) {
32
+ var parentDirectory = path.dirname(currentDirectory);
33
+ console.log("cwd: ", currentDirectory, ", parent: ", parentDirectory);
34
+ if(parentDirectory == currentDirectory) {
35
+ console.error(chalk.red("Could not find installation directory!"));
36
+ return;
37
+ }
38
+ currentDirectory = parentDirectory;
39
+ }
40
+ console.log("Install Directory Found:", currentDirectory);
41
+
42
+ return currentDirectory;
43
+ }
44
+
45
+ function findMainPath(installDirectory) {
46
+ if(!fs.existsSync(installDirectory) || !fs.lstatSync(installDirectory).isDirectory()) {
47
+ console.error("Couldn't locate install directory.");
48
+ return;
49
+ }
50
+
51
+ const iosDirectory = path.join(installDirectory, 'ios');
52
+ var directory;
53
+ fs.readdirSync(iosDirectory).forEach((basename) => {
54
+ const mainPath = path.join(iosDirectory, basename);
55
+ if(fs.lstatSync(mainPath).isDirectory()) {
56
+ const filename = path.join(mainPath, "main.m");
57
+ if(fs.existsSync(filename)) {
58
+ directory = mainPath;
59
+ }
60
+ }
61
+ });
62
+ return directory;
63
+ }
64
+
65
+ function containsStanza(array, stanza, type) {
66
+ for(var i = 0; i < array.length; i++) {
67
+ if(array[i]['$']['android:name'] == stanza[type]['$']['android:name']) {
68
+ return true
69
+ }
70
+ }
71
+ return false;
72
+ }
73
+
74
+ function verifyStanza(array, stanzaString) {
75
+ if(typeof array == "undefined") {
76
+ array = [];
77
+ }
78
+ new xml2js.Parser().parseString(stanzaString, function (err, stanza) {
79
+ const types = Object.getOwnPropertyNames(stanza);
80
+ const type = types[0];
81
+ if( !containsStanza(array, stanza, type) ) {
82
+ console.log("Adding required " + type + " stanza to AndroidManifest.xml");
83
+ array.push( stanza[type] )
84
+ }
85
+ });
86
+ return array;
87
+ }
88
+
89
+ function modifyManifest(installDirectory) {
90
+ let manifestPath = path.join(installDirectory, "android", "app", "src", "main", "AndroidManifest.xml");
91
+ new xml2js.Parser().parseString(fs.readFileSync(manifestPath), function (err, document) {
92
+
93
+ console.log("Adding required receivers to AndroidManifest.xml");
94
+ var receivers = document.manifest.application[0].receiver;
95
+ [
96
+ '<receiver android:name="co.acoustic.mobile.push.sdk.location.LocationBroadcastReceiver" />',
97
+ '<receiver android:name="co.acoustic.mobile.push.sdk.location.LocationUpdateCaller" />',
98
+ '<receiver android:name="co.acoustic.mobile.push.plugin.location.RNAcousticMobilePushBroadcastReceiver"><intent-filter><action android:name="co.acoustic.mobile.push.sdk.NOTIFIER" /></intent-filter></receiver>'
99
+ ].forEach((receiver) => {
100
+ receivers = verifyStanza(receivers, receiver);
101
+ });
102
+ document.manifest.application[0].receiver = receivers;
103
+
104
+ console.log("Adding required services to AndroidManifest.xml");
105
+ var services = document.manifest.application[0].service;
106
+ [
107
+ '<service android:name="co.acoustic.mobile.push.sdk.location.LocationEventsIntentService" />',
108
+ '<service android:name="co.acoustic.mobile.push.sdk.location.LocationSyncAlarmListener" />',
109
+ '<service android:name="co.acoustic.mobile.push.sdk.location.LocationRetrieveService" />'
110
+ ].forEach((service) => {
111
+ services = verifyStanza(services, service);
112
+ });
113
+ document.manifest.application[0].service = services;
114
+
115
+ console.log("Adding fine and coarse location permission to AndroidManifest.xml");
116
+ var permissions = document.manifest['uses-permission'];
117
+ [
118
+ '<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />',
119
+ '<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />'
120
+ ].forEach((permission) => {
121
+ permissions = verifyStanza(permissions, permission);
122
+ });
123
+ document.manifest['uses-permission'] = permissions;
124
+
125
+ var output = new xml2js.Builder().buildObject(document);
126
+ fs.writeFileSync(manifestPath, output);
127
+ });
128
+ }
129
+
130
+ function modifyInfoPlist(mainAppPath) {
131
+ if(!fs.existsSync(mainAppPath) || !fs.lstatSync(mainAppPath).isDirectory()) {
132
+ console.error("Incorrect main app path: " + mainAppPath);
133
+ return;
134
+ }
135
+
136
+ const infoPath = path.join(mainAppPath, "Info.plist");
137
+ if(!fs.existsSync(infoPath) || !fs.lstatSync(infoPath).isFile()) {
138
+ console.error("Couldn't locate Info.plist.");
139
+ return;
140
+ }
141
+
142
+ var infoPlist = plist.parse(fs.readFileSync(infoPath, 'utf8'));
143
+ if(typeof infoPlist.UIBackgroundModes == "undefined") {
144
+ infoPlist.UIBackgroundModes = [];
145
+ }
146
+
147
+ console.log("Adding location to UIBackgroundModes of info.plist");
148
+ var backgroundSet = new Set(infoPlist.UIBackgroundModes);
149
+ backgroundSet.add("location");
150
+ infoPlist.UIBackgroundModes = Array.from(backgroundSet);
151
+
152
+ if(typeof infoPlist.NSLocationAlwaysAndWhenInUseUsageDescription == "undefined") {
153
+ console.log("Adding placeholder value for NSLocationAlwaysAndWhenInUseUsageDescription in info.plist");
154
+ infoPlist.NSLocationAlwaysAndWhenInUseUsageDescription = "Show exciting things nearby!";
155
+ }
156
+
157
+ if(typeof infoPlist.NSLocationAlwaysUsageDescription == "undefined") {
158
+ console.log("Adding placeholder value for NSLocationAlwaysUsageDescription in info.plist");
159
+ infoPlist.NSLocationAlwaysUsageDescription = "Show exciting things nearby!";
160
+ }
161
+
162
+ if(typeof infoPlist.NSLocationWhenInUseUsageDescription == "undefined"){
163
+ console.log("Adding placeholder value for NSLocationWhenInUseUsageDescription in info.plist");
164
+ infoPlist.NSLocationWhenInUseUsageDescription = "Show exciting things nearby!";
165
+ }
166
+
167
+ fs.writeFileSync(infoPath, plist.build(infoPlist), "utf8");
168
+ }
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
+ }
193
+
194
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
195
+ }
196
+
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));
201
+
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."] = "";
204
+
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,
209
+
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,
214
+
215
+ "Location Sync radius is in meters, default 100km":"",
216
+ "syncRadius": 100000,
217
+
218
+ "Specify how long to wait before retrieving a new location from the device, default 5 minutes":"",
219
+ "locationResponsiveness": 300,
220
+
221
+ "Specify the minimum results when looking for locations nearby, default is 1, minimum value is 1":"",
222
+ "minLocationsForSearch": 1,
223
+
224
+ "Specify the maximum results when looking for locations nearby, default is 20, minimum value is 1":"",
225
+ "maxLocationsForSearch": 20,
226
+
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
+ };
231
+ }
232
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
233
+ }
234
+
235
+ 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."));
237
+ return;
238
+ }
239
+
240
+ console.log(chalk.green.bold("Setting up Acoustic Mobile Push Location Plugin"));
241
+ const installDirectory = findInstallDirectory();
242
+ const mainAppPath = findMainPath(installDirectory);
243
+ modifyInfoPlist(mainAppPath);
244
+ updateiOSConfigFile(mainAppPath);
245
+ updateAndroidConfigFile(installDirectory);
246
+ modifyManifest(installDirectory);
247
+
248
+ console.log(chalk.green("Installation Complete!"));
249
+
250
+ console.log(chalk.blue.bold("\nPost Installation Steps\n"));
251
+ console.log(chalk.blue('For react-native 0.59 and lower link the plugin with:'));
252
+ console.log('react-native link react-native-acoustic-mobile-push-location\n');
253
+
254
+ 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");
@@ -0,0 +1,23 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "react-native-acoustic-mobile-push-location"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.description = <<-DESC
10
+ react-native-acoustic-mobile-push-location
11
+ DESC
12
+ s.homepage = "https://github.com/Acoustic-Mobile-Push/React-Native"
13
+ s.license = "Copyright (c) 2019. Acoustic, L.P. All rights reserved"
14
+ s.authors = { "Support" => "support@acoustic.co" }
15
+ s.platforms = { :ios => "12.0" }
16
+ s.source = { :git => "https://github.com/Acoustic-Mobile-Push/React-Native.git", :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/*.{h,m,swift}"
19
+ s.requires_arc = true
20
+
21
+ s.dependency "React"
22
+ end
23
+