react-native-background-location-pro-eval 0.0.0-stage → 1.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.
Files changed (24) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +178 -2
  3. package/android/build.gradle +54 -0
  4. package/android/libs/bgtrackkit.aar +0 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/com/bglocationdemo/tracking/rn/BackgroundLocationProPackage.kt +20 -0
  7. package/ios/BgTrackKit.xcframework/Info.plist +44 -0
  8. package/ios/BgTrackKit.xcframework/ios-arm64/BgTrackKit.framework/BgTrackKit +0 -0
  9. package/ios/BgTrackKit.xcframework/ios-arm64/BgTrackKit.framework/Headers/BgTrackKit-Swift.h +430 -0
  10. package/ios/BgTrackKit.xcframework/ios-arm64/BgTrackKit.framework/Info.plist +0 -0
  11. package/ios/BgTrackKit.xcframework/ios-arm64/BgTrackKit.framework/Modules/module.modulemap +5 -0
  12. package/ios/BgTrackKit.xcframework/ios-arm64_x86_64-simulator/BgTrackKit.framework/BgTrackKit +0 -0
  13. package/ios/BgTrackKit.xcframework/ios-arm64_x86_64-simulator/BgTrackKit.framework/Headers/BgTrackKit-Swift.h +856 -0
  14. package/ios/BgTrackKit.xcframework/ios-arm64_x86_64-simulator/BgTrackKit.framework/Info.plist +0 -0
  15. package/ios/BgTrackKit.xcframework/ios-arm64_x86_64-simulator/BgTrackKit.framework/Modules/module.modulemap +5 -0
  16. package/ios/BgTrackKit.xcframework/ios-arm64_x86_64-simulator/BgTrackKit.framework/_CodeSignature/CodeResources +101 -0
  17. package/ios/BgTrackShim.m +31 -0
  18. package/ios/RCTLocationTracker.h +12 -0
  19. package/ios/RCTLocationTracker.mm +100 -0
  20. package/package.json +60 -4
  21. package/react-native-background-location-pro-eval.podspec +25 -0
  22. package/react-native.config.js +10 -0
  23. package/src/index.ts +8 -0
  24. package/src/specs/NativeLocationTracker.ts +126 -0
@@ -0,0 +1,5 @@
1
+ framework module BgTrackKit {
2
+ header "BgTrackKit-Swift.h"
3
+ requires objc
4
+ export *
5
+ }
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict>
7
+ <key>Info.plist</key>
8
+ <data>
9
+ Mg03LSzOF/Mxsj3PxbDFn4IzjEA=
10
+ </data>
11
+ </dict>
12
+ <key>files2</key>
13
+ <dict/>
14
+ <key>rules</key>
15
+ <dict>
16
+ <key>^.*</key>
17
+ <true/>
18
+ <key>^.*\.lproj/</key>
19
+ <dict>
20
+ <key>optional</key>
21
+ <true/>
22
+ <key>weight</key>
23
+ <real>1000</real>
24
+ </dict>
25
+ <key>^.*\.lproj/locversion.plist$</key>
26
+ <dict>
27
+ <key>omit</key>
28
+ <true/>
29
+ <key>weight</key>
30
+ <real>1100</real>
31
+ </dict>
32
+ <key>^Base\.lproj/</key>
33
+ <dict>
34
+ <key>weight</key>
35
+ <real>1010</real>
36
+ </dict>
37
+ <key>^version.plist$</key>
38
+ <true/>
39
+ </dict>
40
+ <key>rules2</key>
41
+ <dict>
42
+ <key>.*\.dSYM($|/)</key>
43
+ <dict>
44
+ <key>weight</key>
45
+ <real>11</real>
46
+ </dict>
47
+ <key>^(.*/)?\.DS_Store$</key>
48
+ <dict>
49
+ <key>omit</key>
50
+ <true/>
51
+ <key>weight</key>
52
+ <real>2000</real>
53
+ </dict>
54
+ <key>^.*</key>
55
+ <true/>
56
+ <key>^.*\.lproj/</key>
57
+ <dict>
58
+ <key>optional</key>
59
+ <true/>
60
+ <key>weight</key>
61
+ <real>1000</real>
62
+ </dict>
63
+ <key>^.*\.lproj/locversion.plist$</key>
64
+ <dict>
65
+ <key>omit</key>
66
+ <true/>
67
+ <key>weight</key>
68
+ <real>1100</real>
69
+ </dict>
70
+ <key>^Base\.lproj/</key>
71
+ <dict>
72
+ <key>weight</key>
73
+ <real>1010</real>
74
+ </dict>
75
+ <key>^Info\.plist$</key>
76
+ <dict>
77
+ <key>omit</key>
78
+ <true/>
79
+ <key>weight</key>
80
+ <real>20</real>
81
+ </dict>
82
+ <key>^PkgInfo$</key>
83
+ <dict>
84
+ <key>omit</key>
85
+ <true/>
86
+ <key>weight</key>
87
+ <real>20</real>
88
+ </dict>
89
+ <key>^embedded\.provisionprofile$</key>
90
+ <dict>
91
+ <key>weight</key>
92
+ <real>20</real>
93
+ </dict>
94
+ <key>^version\.plist$</key>
95
+ <dict>
96
+ <key>weight</key>
97
+ <real>20</real>
98
+ </dict>
99
+ </dict>
100
+ </dict>
101
+ </plist>
@@ -0,0 +1,31 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ #import <BgTrackKit/BgTrackKit-Swift.h>
5
+
6
+ // Drop-in launch hook: the host app needs no AppDelegate changes. Registering in +load means this
7
+ // runs before UIApplication starts, and the didFinishLaunching notification fires on normal starts
8
+ // and on headless background relaunches (significant-location-change), at which point the engine
9
+ // registers its BGTask, reconnects the background upload session, and revives tracking if desired.
10
+ @interface BgTrackShim : NSObject
11
+ @end
12
+
13
+ @implementation BgTrackShim
14
+
15
+ + (void)load
16
+ {
17
+ #if defined(DEBUG) || defined(POD_CONFIGURATION_DEBUG)
18
+ [BGTrackingController.shared applyRuntimeProfile:0x6B3D91];
19
+ #else
20
+ [BGTrackingController.shared applyRuntimeProfile:0x1C04E2];
21
+ #endif
22
+
23
+ [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification
24
+ object:nil
25
+ queue:[NSOperationQueue mainQueue]
26
+ usingBlock:^(NSNotification *_Nonnull note) {
27
+ [BGTrackingController.shared bootstrap];
28
+ }];
29
+ }
30
+
31
+ @end
@@ -0,0 +1,12 @@
1
+ #import <NativeLocationTrackerSpec/NativeLocationTrackerSpec.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ /**
6
+ * JSI TurboModule `LocationTracker`. JS only steers and observes; the pipeline runs in
7
+ * Swift (TrackingController / LocationEngine) whether or not this module exists.
8
+ */
9
+ @interface RCTLocationTracker : NativeLocationTrackerSpecBase <NativeLocationTrackerSpec>
10
+ @end
11
+
12
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,100 @@
1
+ #import "RCTLocationTracker.h"
2
+
3
+ #import <CoreLocation/CoreLocation.h>
4
+ #import <UIKit/UIKit.h>
5
+
6
+ // Generated ObjC interface for the precompiled engine, shipped inside BgTrackKit.xcframework.
7
+ #import <BgTrackKit/BgTrackKit-Swift.h>
8
+
9
+ @interface RCTLocationTracker () <BGTrackingEventSink>
10
+ @end
11
+
12
+ @implementation RCTLocationTracker
13
+
14
+ RCT_EXPORT_MODULE(LocationTracker)
15
+
16
+ - (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
17
+ {
18
+ [super setEventEmitterCallback:eventEmitterCallbackWrapper];
19
+ [BGTrackingController.shared attach:self];
20
+ }
21
+
22
+ - (void)invalidate
23
+ {
24
+ [BGTrackingController.shared detach:self];
25
+ }
26
+
27
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
28
+ (const facebook::react::ObjCTurboModule::InitParams &)params
29
+ {
30
+ return std::make_shared<facebook::react::NativeLocationTrackerSpecJSI>(params);
31
+ }
32
+
33
+ - (void)startTracking:(NSString *)serverUrl
34
+ {
35
+ [BGTrackingController.shared startTracking:serverUrl];
36
+ }
37
+
38
+ - (void)stopTracking
39
+ {
40
+ [BGTrackingController.shared stopTracking];
41
+ }
42
+
43
+ - (NSDictionary *)getStatus
44
+ {
45
+ return [BGTrackingController.shared status];
46
+ }
47
+
48
+ - (void)syncNow
49
+ {
50
+ [BGTrackingController.shared syncNow];
51
+ }
52
+
53
+ - (void)setDemoMode:(BOOL)enabled
54
+ {
55
+ [BGTrackingController.shared setDemoMode:enabled];
56
+ }
57
+
58
+ - (void)requestIgnoreBatteryOptimizations
59
+ {
60
+ [BGTrackingController.shared openSettings];
61
+ }
62
+
63
+ - (void)openExactAlarmSettings
64
+ {
65
+ [BGTrackingController.shared openSettings];
66
+ }
67
+
68
+ - (void)requestLocationPermission:(BOOL)always
69
+ {
70
+ [BGTrackingController.shared requestLocationPermission:always];
71
+ }
72
+
73
+ - (void)setTrackingProfile:(NSString *)profile
74
+ {
75
+ [BGTrackingController.shared setTrackingProfile:profile];
76
+ }
77
+
78
+ - (void)setMotionPermissionOptIn:(BOOL)enabled
79
+ {
80
+ [BGTrackingController.shared setMotionPermissionOptIn:enabled];
81
+ }
82
+
83
+ - (void)setSyncPolicy:(double)batchSize maxBackoffMs:(double)maxBackoffMs maxAttempts:(double)maxAttempts
84
+ {
85
+ [BGTrackingController.shared setSyncPolicy:batchSize maxBackoffMs:maxBackoffMs maxAttempts:maxAttempts];
86
+ }
87
+
88
+ #pragma mark - BGTrackingEventSink
89
+
90
+ - (void)onLocationUpdate:(NSDictionary *)event
91
+ {
92
+ [self emitOnLocationUpdate:event];
93
+ }
94
+
95
+ - (void)onSyncStatus:(NSDictionary *)event
96
+ {
97
+ [self emitOnSyncStatus:event];
98
+ }
99
+
100
+ @end
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "react-native-background-location-pro-eval",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Production-grade background location tracking for React Native (New Architecture). Drop-in TurboModule. Free evaluation build: full pipeline in development; production use requires a license. Source license via GitHub Sponsors.",
5
+ "main": "src/index.ts",
6
+ "types": "src/index.ts",
7
+ "scripts": {
8
+ "prepack": "node scripts/assert-no-source-in-tarball.js"
9
+ },
10
+ "files": [
11
+ "src",
12
+ "ios/*.h",
13
+ "ios/*.m",
14
+ "ios/*.mm",
15
+ "ios/BgTrackKit.xcframework",
16
+ "android/build.gradle",
17
+ "android/src",
18
+ "android/libs/bgtrackkit.aar",
19
+ "react-native.config.js",
20
+ "react-native-background-location-pro-eval.podspec",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "keywords": [
25
+ "react-native",
26
+ "ios",
27
+ "android",
28
+ "background",
29
+ "location",
30
+ "geolocation",
31
+ "tracking",
32
+ "turbomodule",
33
+ "new-architecture"
34
+ ],
35
+ "license": "SEE LICENSE IN LICENSE",
36
+ "author": "Punith M <punithm300@gmail.com>",
37
+ "homepage": "https://github.com/sponsors/126punith",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/126punith/react-native-background-location-pro-eval.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/126punith/react-native-background-location-pro-eval/issues"
44
+ },
45
+ "peerDependencies": {
46
+ "react": "*",
47
+ "react-native": "*"
48
+ },
49
+ "codegenConfig": {
50
+ "name": "NativeLocationTrackerSpec",
51
+ "type": "modules",
52
+ "jsSrcsDir": "src/specs",
53
+ "android": {
54
+ "javaPackageName": "com.bglocationdemo.tracking"
55
+ },
56
+ "ios": {
57
+ "modulesProvider": {
58
+ "LocationTracker": "RCTLocationTracker"
59
+ }
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,25 @@
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-background-location-pro-eval'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.homepage = package['homepage']
10
+ s.license = { :type => 'Commercial', :file => 'LICENSE' }
11
+ s.authors = package['author']
12
+
13
+ s.platform = :ios, '15.1'
14
+ s.source = { :git => 'https://github.com/126punith/react-native-background-location-pro-eval.git', :tag => "v#{s.version}" }
15
+
16
+ # Only the thin bridge glue ships as source; the tracking engine ships as a precompiled binary.
17
+ s.source_files = 'ios/*.{h,m,mm}'
18
+ s.vendored_frameworks = 'ios/BgTrackKit.xcframework'
19
+ s.requires_arc = true
20
+
21
+ s.libraries = 'sqlite3'
22
+
23
+ # New Architecture: wires up React-Core, ReactCodegen and the generated spec base.
24
+ install_modules_dependencies(s)
25
+ end
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ android: {
5
+ packageImportPath: 'import com.bglocationdemo.tracking.rn.BackgroundLocationProPackage;',
6
+ packageInstance: 'new BackgroundLocationProPackage()',
7
+ },
8
+ },
9
+ },
10
+ };
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ export {default} from './specs/NativeLocationTracker';
2
+ export type {
3
+ LocationEvent,
4
+ TrackingProfile,
5
+ SyncEvent,
6
+ Status,
7
+ Spec,
8
+ } from './specs/NativeLocationTracker';
@@ -0,0 +1,126 @@
1
+ import type {CodegenTypes, TurboModule} from 'react-native';
2
+ import {TurboModuleRegistry} from 'react-native';
3
+
4
+ /** One accepted fix, pushed from the native location engine as soon as it is persisted. */
5
+ export type LocationEvent = {
6
+ id: string;
7
+ latitude: number;
8
+ longitude: number;
9
+ /** Horizontal accuracy radius in meters. */
10
+ accuracy: number;
11
+ /** Meters per second. */
12
+ speed: number;
13
+ /** Capture time, epoch milliseconds. */
14
+ timestamp: number;
15
+ /** Points on disk not yet acknowledged by the server, including this one. */
16
+ pending: number;
17
+ };
18
+
19
+ /**
20
+ * - `continuous_fitness`: never pauses on its own; bound only to a 5 m distance filter until `stopTracking()`.
21
+ * - `balanced`: always subscribed with a 20 m displacement gate.
22
+ * - `adaptive_low_power` (default): `balanced` plus a native motion gate that parks GPS while the
23
+ * device is stationary. Any motion-sensor failure falls back to `balanced`; it never pauses silently.
24
+ */
25
+ export type TrackingProfile = 'continuous_fitness' | 'balanced' | 'adaptive_low_power';
26
+
27
+ /** Pushed whenever connectivity, the queue, or the sync outcome changes. */
28
+ export type SyncEvent = {
29
+ running: boolean;
30
+ online: boolean;
31
+ pending: number;
32
+ synced: number;
33
+ lastSyncAt: number;
34
+ /** Consecutive failures of the in-flight batch; 0 when healthy. */
35
+ retryAttempt: number;
36
+ /** Epoch ms of the next scheduled attempt; 0 when none is pending. */
37
+ nextRetryAt: number;
38
+ /** True while the motion gate has parked GPS because the device is stationary. */
39
+ motionGateActive: boolean;
40
+ /** stationary | walking | running | driving | cycling | moving | unknown | unsupported */
41
+ motionState: string;
42
+ /** Human-readable status. Errors start with a stable `[code]` prefix. */
43
+ message: string;
44
+ };
45
+
46
+ /** Snapshot returned synchronously over JSI from in-memory native state. */
47
+ export type Status = {
48
+ running: boolean;
49
+ /** Tracking was requested and not stopped; the watchdog revives the pipeline while true. */
50
+ desired: boolean;
51
+ online: boolean;
52
+ pending: number;
53
+ synced: number;
54
+ lastLocationAt: number;
55
+ lastSyncAt: number;
56
+ message: string;
57
+ serverUrl: string;
58
+ deviceId: string;
59
+ /** Background App Refresh is available, so the BGTask watchdog can run. */
60
+ exactAlarmsAllowed: boolean;
61
+ /** Low Power Mode is off. */
62
+ batteryUnrestricted: boolean;
63
+ /** Sync every 5 s instead of 30 s so the live map updates quickly during demos. */
64
+ demoMode: boolean;
65
+ /** CLAuthorizationStatus: notDetermined | whenInUse | always | denied | restricted. */
66
+ authorization: string;
67
+ /** Full (precise) accuracy authorization granted. */
68
+ preciseLocation: boolean;
69
+ trackingProfile: string;
70
+ motionGateActive: boolean;
71
+ /** stationary | walking | running | driving | cycling | moving | unknown | unsupported */
72
+ motionState: string;
73
+ /** Sensor driving the gate: coremotion | none. */
74
+ motionSource: string;
75
+ /** Motion & Fitness permission: granted | denied | notRequested | unavailable. */
76
+ motionPermission: string;
77
+ /** Always false on iOS; Motion & Fitness is requested lazily by the `adaptive_low_power` profile. */
78
+ motionPermissionOptIn: boolean;
79
+ /** Points moved to the dead-letter state after `maxAttempts` non-retryable rejections. */
80
+ rejected: number;
81
+ retryAttempt: number;
82
+ nextRetryAt: number;
83
+ /** Last sync failure, e.g. `http_503` or `TimedOut`; empty after a success. */
84
+ lastSyncError: string;
85
+ /**
86
+ * Evaluation build only: `debug` while evaluating, `release` when evaluation is not available in
87
+ * this build.
88
+ */
89
+ buildTier: string;
90
+ };
91
+
92
+ export interface Spec extends TurboModule {
93
+ /** Persists the server URL, marks tracking as desired, starts the location engine and arms the watchdog. */
94
+ startTracking(serverUrl: string): void;
95
+ /** Clears the desired flag, cancels the watchdog and stops collection after a final flush. Buffered points stay on disk. */
96
+ stopTracking(): void;
97
+ /** Synchronous JSI call; never blocks on I/O. */
98
+ getStatus(): Status;
99
+ /** Forces an immediate sync attempt (still skipped while offline). */
100
+ syncNow(): void;
101
+ /** Persisted; switches the sync tick between 5 s (demo) and 30 s. Batch size and idempotency are unchanged. */
102
+ setDemoMode(enabled: boolean): void;
103
+ /** iOS has no battery-optimization exemption; opens the app's Settings page. */
104
+ requestIgnoreBatteryOptimizations(): void;
105
+ /** Opens the app's Settings page (Background App Refresh lives there). */
106
+ openExactAlarmSettings(): void;
107
+ /**
108
+ * Requests When-In-Use first; with `always` it escalates to Always once When-In-Use is granted,
109
+ * or opens Settings when iOS will no longer show the prompt.
110
+ */
111
+ requestLocationPermission(always: boolean): void;
112
+ /** Persisted and applied live (no restart). Unknown values are rejected with a `[invalid_profile]` status. */
113
+ setTrackingProfile(profile: string): void;
114
+ /** Android-only (Activity Recognition tier); a no-op on iOS, kept so the JS contract matches. */
115
+ setMotionPermissionOptIn(enabled: boolean): void;
116
+ /**
117
+ * Persisted. `maxBackoffMs` caps the jittered exponential backoff; `maxAttempts` is how many
118
+ * non-retryable 4xx rejections a batch may get before it is dead-lettered (0 = keep retrying).
119
+ */
120
+ setSyncPolicy(batchSize: number, maxBackoffMs: number, maxAttempts: number): void;
121
+
122
+ readonly onLocationUpdate: CodegenTypes.EventEmitter<LocationEvent>;
123
+ readonly onSyncStatus: CodegenTypes.EventEmitter<SyncEvent>;
124
+ }
125
+
126
+ export default TurboModuleRegistry.getEnforcing<Spec>('LocationTracker');