react-native-background-geolocation 4.8.0 → 4.8.1
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/CHANGELOG.md +3 -0
- package/package.json +2 -14
- package/react-native.config.js +0 -20
- package/scripts/postlink.js +0 -146
- package/scripts/postunlink.js +0 -128
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.8.1 — 2022-06-28
|
|
4
|
+
* Fix issue for react-native 0.69: They made a breaking change with the old, unused react-native.config.js, causing builds to fail. Simply delete the file `react-native.config.js`.
|
|
5
|
+
|
|
3
6
|
## 4.8.0 — 2022-06-21
|
|
4
7
|
* [Android] Fix bug in `onProviderChange` event: not properly detecting when location-services disabled.
|
|
5
8
|
* [Android] __Android 12__: Guard `Context.startForegroundService` with `try / catch`: the plugin will now catch exception `ForegroundServiceStartNotAllowedException` and automatically retry with an `AlarmManager` *oneShot* event.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-background-geolocation",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "The most sophisticated cross-platform background location-tracking & geofencing module with battery-conscious motion-detection intelligence",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -26,24 +26,12 @@
|
|
|
26
26
|
"bugs": {
|
|
27
27
|
"url": "https://github.com/transistorsoft/react-native-background-geolocation/issues"
|
|
28
28
|
},
|
|
29
|
-
"rnpm": {
|
|
30
|
-
"commands": {
|
|
31
|
-
"postlink": "node node_modules/react-native-background-geolocation/scripts/postlink.js",
|
|
32
|
-
"postunlink": "node node_modules/react-native-background-geolocation/scripts/postunlink.js"
|
|
33
|
-
},
|
|
34
|
-
"ios": {
|
|
35
|
-
"sharedLibraries": [
|
|
36
|
-
"libsqlite3",
|
|
37
|
-
"libz"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
29
|
"homepage": "https://www.transistorsoft.com/shop/products/react-native-background-geolocation",
|
|
42
30
|
"peerDependencies": {
|
|
43
31
|
"react-native": ">=0.36.0"
|
|
44
32
|
},
|
|
45
33
|
"dependencies": {
|
|
46
|
-
"react-native-background-fetch": "~4.1.
|
|
34
|
+
"react-native-background-fetch": "~4.1.1"
|
|
47
35
|
},
|
|
48
36
|
"devDependencies": {
|
|
49
37
|
"@transistorsoft/typedoc-theme": "^2.0.8",
|
package/react-native.config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// config for a library is scoped under "dependency" key
|
|
3
|
-
dependency: {
|
|
4
|
-
platforms: {
|
|
5
|
-
ios: {
|
|
6
|
-
"sharedLibraries": [
|
|
7
|
-
"libsqlite3",
|
|
8
|
-
"libz"
|
|
9
|
-
]
|
|
10
|
-
},
|
|
11
|
-
android: {}, // projects are grouped into "platforms"
|
|
12
|
-
},
|
|
13
|
-
assets: [], // stays the same
|
|
14
|
-
// hooks are considered anti-pattern, please avoid them
|
|
15
|
-
hooks: {
|
|
16
|
-
"postlink": "node node_modules/react-native-background-geolocation/scripts/postlink.js",
|
|
17
|
-
"postunlink": "node node_modules/react-native-background-geolocation/scripts/postunlink.js"
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
package/scripts/postlink.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const xcode = require('xcode');
|
|
6
|
-
const PbxFile = require('xcode/lib/pbxFile');
|
|
7
|
-
const helpers = require('./xcode-helpers');
|
|
8
|
-
|
|
9
|
-
const projectDirectory = process.cwd();
|
|
10
|
-
const moduleDirectory = path.resolve(__dirname, '..');
|
|
11
|
-
|
|
12
|
-
////
|
|
13
|
-
// iOS
|
|
14
|
-
//
|
|
15
|
-
const sourceDirectory = path.join(projectDirectory, 'ios');
|
|
16
|
-
const xcodeProjectDirectory = helpers.findProject(sourceDirectory);
|
|
17
|
-
|
|
18
|
-
const projectConfig = {
|
|
19
|
-
sourceDir: sourceDirectory,
|
|
20
|
-
pbxprojPath: path.join(
|
|
21
|
-
projectDirectory,
|
|
22
|
-
'ios',
|
|
23
|
-
xcodeProjectDirectory,
|
|
24
|
-
'project.pbxproj'
|
|
25
|
-
),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const pathToFramework = path.relative(
|
|
29
|
-
projectConfig.sourceDir,
|
|
30
|
-
path.join(
|
|
31
|
-
moduleDirectory,
|
|
32
|
-
'ios',
|
|
33
|
-
'RNBackgroundGeolocation',
|
|
34
|
-
'TSLocationManager.framework'
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const project = xcode.project(projectConfig.pbxprojPath).parseSync();
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* There is a method in node-xcode that offers similar functionality than what
|
|
43
|
-
* is implemented below `addFramework` (https://github.com/alunny/node-xcode/blob/ffb938b/lib/pbxProject.js#L300)
|
|
44
|
-
* but unfortunately it won't work for our use-case because there are two other
|
|
45
|
-
* methods in node-xcode that are being used by `addFramework` that don't work
|
|
46
|
-
* as expected:
|
|
47
|
-
* 1 `addToFrameworksPbxGroup` fails if no group with the name "Frameworks" exists
|
|
48
|
-
* https://github.com/alunny/node-xcode/blob/ffb938b/lib/pbxProject.js#L641
|
|
49
|
-
* - https://github.com/alunny/node-xcode/issues/43
|
|
50
|
-
* - this issue could be worked around by just checking if the group exists and
|
|
51
|
-
* creating it if it doesn't exist before executing `addFramework`
|
|
52
|
-
* 2 `addToFrameworkSearchPaths` doesn't work with react-native:
|
|
53
|
-
* https://github.com/alunny/node-xcode/blob/ffb938b/lib/pbxProject.js#L1125
|
|
54
|
-
* - https://github.com/alunny/node-xcode/issues/91
|
|
55
|
-
* - https://github.com/alunny/node-xcode/pull/99
|
|
56
|
-
* - the issue there is that https://github.com/alunny/node-xcode/blob/ffb938b/lib/pbxProject.js#L1133
|
|
57
|
-
* in react-native projects the "PRODUCT_NAME" is "$(TARGET_NAME)", so it won't
|
|
58
|
-
* be visited by this method.
|
|
59
|
-
* And even if the name would be correct it still wouldn't work correctly for
|
|
60
|
-
* react-native projects, because not all targets should get the library added
|
|
61
|
-
* for example: react-native creates *tests and *tvOs and *tvOstests targets.
|
|
62
|
-
*/
|
|
63
|
-
const file = new PbxFile(pathToFramework);
|
|
64
|
-
file.uuid = project.generateUuid();
|
|
65
|
-
file.fileRef = project.generateUuid();
|
|
66
|
-
file.path = pathToFramework;
|
|
67
|
-
file.target = project.getFirstTarget().uuid;
|
|
68
|
-
|
|
69
|
-
if (!project.hasFile(file.path)) {
|
|
70
|
-
project.addToPbxBuildFileSection(file);
|
|
71
|
-
project.addToPbxFileReferenceSection(file);
|
|
72
|
-
// addToFrameworksPbxGroup crashes when it can't find a group named "Frameworks"
|
|
73
|
-
if (!project.pbxGroupByName('Frameworks')) {
|
|
74
|
-
project.addPbxGroup([], 'Frameworks');
|
|
75
|
-
}
|
|
76
|
-
project.addToFrameworksPbxGroup(file);
|
|
77
|
-
project.addToPbxFrameworksBuildPhase(file);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Is this a Cocoapods installation?
|
|
81
|
-
const podFile = path.join(sourceDirectory, 'Podfile');
|
|
82
|
-
const hasPodfile = fs.existsSync(podFile);
|
|
83
|
-
if (!hasPodfile) {
|
|
84
|
-
// Only add FRAMEWORK_SEARCH_PATHS for non-Cocoapod installation
|
|
85
|
-
helpers.addToFrameworkSearchPaths(
|
|
86
|
-
project,
|
|
87
|
-
'$(PROJECT_DIR)/' +
|
|
88
|
-
path.relative(
|
|
89
|
-
projectConfig.sourceDir,
|
|
90
|
-
path.join(moduleDirectory, 'ios')
|
|
91
|
-
),
|
|
92
|
-
true
|
|
93
|
-
);
|
|
94
|
-
} else {
|
|
95
|
-
helpers.addToFrameworkSearchPaths(
|
|
96
|
-
project,
|
|
97
|
-
'$(inherited)',
|
|
98
|
-
false
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// enable BackgroundModes in xcode project without overriding any previously
|
|
104
|
-
// defined values in the project file.
|
|
105
|
-
// That's why we deep clone all previously defined target attributes and extend
|
|
106
|
-
// them with our target attributes.
|
|
107
|
-
const targetAttributes = helpers.getTargetAttributes(project);
|
|
108
|
-
const systemCapabilities = Object.assign({}, (targetAttributes.SystemCapabilities || {}), {
|
|
109
|
-
'com.apple.BackgroundModes': Object.assign(
|
|
110
|
-
{},
|
|
111
|
-
targetAttributes['com.apple.BackgroundModes'] || {},
|
|
112
|
-
{ enabled: true }
|
|
113
|
-
),
|
|
114
|
-
});
|
|
115
|
-
if (targetAttributes.SystemCapabilities) {
|
|
116
|
-
targetAttributes.SystemCapabilities = systemCapabilities;
|
|
117
|
-
} else {
|
|
118
|
-
project.addTargetAttribute('SystemCapabilities', systemCapabilities);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// add "location" background mode to Info.plist file
|
|
122
|
-
const plist = helpers.readPlist(projectConfig.sourceDir, project);
|
|
123
|
-
const UIBackgroundModes = plist.UIBackgroundModes || [];
|
|
124
|
-
if (UIBackgroundModes.indexOf('location') === -1) {
|
|
125
|
-
plist.UIBackgroundModes = UIBackgroundModes.concat('location');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Add NSLocationAlwaysUsageDescription
|
|
129
|
-
if (!plist.NSLocationAlwaysUsageDescription) {
|
|
130
|
-
plist.NSLocationAlwaysUsageDescription = "CHANGEME: Location Always Usage Description";
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Add NSLocationAlwaysAndWhenInUseUsageDescription
|
|
134
|
-
if (!plist.NSLocationAlwaysAndWhenInUseUsageDescription) {
|
|
135
|
-
plist.NSLocationAlwaysAndWhenInUseUsageDescription = "CHANGEME: Location Always And When In Use Usage Description";
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Add NSMotionUsageDescription
|
|
139
|
-
if (!plist.NSMotionUsageDescription) {
|
|
140
|
-
plist.NSMotionUsageDescription = "CHANGEME: Motion updates increase battery efficiency by intelligently toggling location-services when device is detected to be moving";
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
helpers.writePlist(projectConfig.sourceDir, project, plist);
|
|
144
|
-
fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync());
|
|
145
|
-
|
|
146
|
-
|
package/scripts/postunlink.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const xcode = require('xcode');
|
|
6
|
-
const PbxFile = require('xcode/lib/pbxFile');
|
|
7
|
-
const helpers = require('./xcode-helpers');
|
|
8
|
-
|
|
9
|
-
const projectDirectory = process.cwd();
|
|
10
|
-
const moduleDirectory = path.resolve(__dirname, '..');
|
|
11
|
-
const sourceDirectory = path.join(projectDirectory, 'ios');
|
|
12
|
-
const xcodeProjectDirectory = helpers.findProject(sourceDirectory);
|
|
13
|
-
|
|
14
|
-
const projectConfig = {
|
|
15
|
-
sourceDir: sourceDirectory,
|
|
16
|
-
pbxprojPath: path.join(
|
|
17
|
-
projectDirectory,
|
|
18
|
-
'ios',
|
|
19
|
-
xcodeProjectDirectory,
|
|
20
|
-
'project.pbxproj'
|
|
21
|
-
),
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const pathToFramework = path.relative(
|
|
25
|
-
projectConfig.sourceDir,
|
|
26
|
-
path.join(
|
|
27
|
-
moduleDirectory,
|
|
28
|
-
'ios',
|
|
29
|
-
'RNBackgroundGeolocation',
|
|
30
|
-
'TSLocationManager.framework'
|
|
31
|
-
)
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const project = xcode.project(projectConfig.pbxprojPath).parseSync();
|
|
35
|
-
|
|
36
|
-
const file = new PbxFile(pathToFramework);
|
|
37
|
-
file.target = project.getFirstTarget().uuid;
|
|
38
|
-
|
|
39
|
-
project.removeFromPbxBuildFileSection(file);
|
|
40
|
-
project.removeFromPbxFileReferenceSection(file);
|
|
41
|
-
if (project.pbxGroupByName('Frameworks')) {
|
|
42
|
-
project.removeFromFrameworksPbxGroup(file);
|
|
43
|
-
}
|
|
44
|
-
project.removeFromPbxFrameworksBuildPhase(file);
|
|
45
|
-
|
|
46
|
-
// Is this a Cocoapods installation?
|
|
47
|
-
const podFile = path.join(sourceDirectory, 'Podfile');
|
|
48
|
-
const hasPodfile = fs.existsSync(podFile);
|
|
49
|
-
if (!hasPodfile) {
|
|
50
|
-
helpers.removeFromFrameworkSearchPaths(
|
|
51
|
-
project,
|
|
52
|
-
'$(PROJECT_DIR)/' +
|
|
53
|
-
path.relative(
|
|
54
|
-
projectConfig.sourceDir,
|
|
55
|
-
path.join(moduleDirectory, 'ios')
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// disable BackgroundModes and remove "fetch" mode from plist file
|
|
61
|
-
const systemCapabilities = helpers.getTargetAttributes(project).SystemCapabilities;
|
|
62
|
-
if (systemCapabilities && systemCapabilities['com.apple.BackgroundModes']) {
|
|
63
|
-
delete systemCapabilities['com.apple.BackgroundModes'].enabled;
|
|
64
|
-
if (Object.keys(systemCapabilities['com.apple.BackgroundModes']).length === 0) {
|
|
65
|
-
delete systemCapabilities['com.apple.BackgroundModes'];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (Object.keys(systemCapabilities).length === 0) {
|
|
69
|
-
project.removeTargetAttribute('SystemCapabilities');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const plist = helpers.readPlist(projectConfig.sourceDir, project);
|
|
74
|
-
if (Array.isArray(plist.UIBackgroundModes)) {
|
|
75
|
-
plist.UIBackgroundModes = plist.UIBackgroundModes.filter(
|
|
76
|
-
mode => mode !== 'location'
|
|
77
|
-
);
|
|
78
|
-
if (plist.UIBackgroundModes.length === 0) {
|
|
79
|
-
delete plist.UIBackgroundModes;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
helpers.writePlist(projectConfig.sourceDir, project, plist);
|
|
84
|
-
fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync());
|
|
85
|
-
|
|
86
|
-
////
|
|
87
|
-
// Android
|
|
88
|
-
// - Remove maven url
|
|
89
|
-
// maven {
|
|
90
|
-
// url "$rootDir/../node_modules/react-native-background-geolocation/android/libs"
|
|
91
|
-
// }
|
|
92
|
-
//
|
|
93
|
-
const androidSrcDir = path.join(projectDirectory, 'android');
|
|
94
|
-
const gradleFile = path.join(androidSrcDir, 'build.gradle');
|
|
95
|
-
const moduleName = (process.platform === 'win32') ? moduleDirectory.split('\\').pop() : moduleDirectory.split('/').pop();
|
|
96
|
-
|
|
97
|
-
fs.readFile(gradleFile, 'utf8', function (err,data) {
|
|
98
|
-
if (err) {
|
|
99
|
-
return console.log(err);
|
|
100
|
-
}
|
|
101
|
-
var re = new RegExp("[\\t?\\s?]+maven\\s?\\{[\\n?\\s?\\t?]+url.*" + moduleName + "\\/.*[\\n?\\t?\\s?]+\\}", "gm");
|
|
102
|
-
|
|
103
|
-
if (data.match(re)) {
|
|
104
|
-
fs.writeFile(gradleFile, data.replace(re, ''), 'utf8', function (err) {
|
|
105
|
-
if (err) return console.log(err);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Remove method-call purgeBackgroundGeolocationDebugResources(applicationVariants)
|
|
112
|
-
const appGradleFile = path.join(androidSrcDir, 'app', 'build.gradle');
|
|
113
|
-
const purgeMethodName = "purgeBackgroundGeolocationDebugResources";
|
|
114
|
-
|
|
115
|
-
fs.readFile(appGradleFile, 'utf8', function(err, data) {
|
|
116
|
-
if (err) {
|
|
117
|
-
return console.log(err);
|
|
118
|
-
}
|
|
119
|
-
var purgeMethodRE = new RegExp("^[\\s\\t]+" + purgeMethodName + "\\(applicationVariants\\).*$[\\s\\n]+(.*)", "gm");
|
|
120
|
-
|
|
121
|
-
if (purgeMethodRE.test(data)) {
|
|
122
|
-
data = data.replace(purgeMethodRE, '\t$1');
|
|
123
|
-
}
|
|
124
|
-
fs.writeFile(appGradleFile, data, 'utf8', function (err) {
|
|
125
|
-
if (err) return console.log(err);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|