@capgo/capacitor-ibeacon 8.1.9 → 8.1.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.
package/README.md
CHANGED
|
@@ -34,24 +34,53 @@ npx cap sync
|
|
|
34
34
|
|
|
35
35
|
### iOS
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
#### Step 1: Configure Info.plist
|
|
38
|
+
|
|
39
|
+
Add the following keys to your `ios/App/App/Info.plist` file:
|
|
38
40
|
|
|
39
41
|
```xml
|
|
42
|
+
<!-- Required: Location permission for beacon detection -->
|
|
40
43
|
<key>NSLocationWhenInUseUsageDescription</key>
|
|
41
44
|
<string>This app needs location access to detect nearby beacons</string>
|
|
42
45
|
|
|
46
|
+
<!-- Required for background monitoring: Always authorization -->
|
|
43
47
|
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
|
44
48
|
<string>This app needs location access to monitor beacons in the background</string>
|
|
45
49
|
|
|
50
|
+
<!-- Required: Bluetooth usage (iOS 13+) -->
|
|
46
51
|
<key>NSBluetoothAlwaysUsageDescription</key>
|
|
47
52
|
<string>This app uses Bluetooth to detect nearby beacons</string>
|
|
48
53
|
|
|
54
|
+
<!-- Required for iOS 12 and earlier -->
|
|
55
|
+
<key>NSBluetoothPeripheralUsageDescription</key>
|
|
56
|
+
<string>This app uses Bluetooth to detect and advertise as beacons</string>
|
|
57
|
+
|
|
58
|
+
<!-- Required for background beacon monitoring -->
|
|
49
59
|
<key>UIBackgroundModes</key>
|
|
50
60
|
<array>
|
|
51
61
|
<string>location</string>
|
|
62
|
+
<string>bluetooth-central</string>
|
|
52
63
|
</array>
|
|
53
64
|
```
|
|
54
65
|
|
|
66
|
+
#### Step 2: Enable Capabilities in Xcode
|
|
67
|
+
|
|
68
|
+
1. Open your project in Xcode: `ios/App/App.xcworkspace`
|
|
69
|
+
2. Select your app target
|
|
70
|
+
3. Go to the "Signing & Capabilities" tab
|
|
71
|
+
4. Click "+ Capability" and add "Background Modes"
|
|
72
|
+
5. Check the following options:
|
|
73
|
+
- ✅ **Location updates** (required for background beacon monitoring)
|
|
74
|
+
- ✅ **Uses Bluetooth LE accessories** (required for beacon detection)
|
|
75
|
+
|
|
76
|
+
#### Permissions Required
|
|
77
|
+
|
|
78
|
+
- **When In Use**: For foreground beacon ranging and monitoring
|
|
79
|
+
- **Always**: Required for background beacon monitoring (detecting beacons when app is not active)
|
|
80
|
+
- **Bluetooth**: Automatically granted on iOS 13+ when using CoreLocation for beacons
|
|
81
|
+
|
|
82
|
+
> **Note**: The plugin uses CoreLocation for beacon detection, which handles Bluetooth scanning internally. Direct Bluetooth permissions are only needed if your app also uses CoreBluetooth for other purposes (e.g., advertising as a beacon).
|
|
83
|
+
|
|
55
84
|
### Android
|
|
56
85
|
|
|
57
86
|
The plugin automatically includes all required permissions and dependencies. No manual configuration needed.
|
|
@@ -384,17 +413,100 @@ interface BeaconAdvertisingOptions {
|
|
|
384
413
|
|
|
385
414
|
## Important Notes
|
|
386
415
|
|
|
387
|
-
1. **iOS Background Monitoring**: To monitor beacons in the background, you need
|
|
416
|
+
1. **iOS Background Monitoring**: To monitor beacons in the background, you need:
|
|
417
|
+
- "Always" location authorization (`requestAlwaysAuthorization()`)
|
|
418
|
+
- Background Modes capability enabled in Xcode
|
|
419
|
+
- `UIBackgroundModes` with both `location` and `bluetooth-central` in Info.plist
|
|
420
|
+
|
|
421
|
+
2. **iOS Xcode Configuration**: Adding Info.plist keys alone is not enough. You **must** enable Background Modes capability in Xcode (see Configuration section above). This is the most common setup issue.
|
|
422
|
+
|
|
423
|
+
3. **Android Library**: This plugin includes the AltBeacon Android Beacon Library (2.21.2) automatically.
|
|
424
|
+
|
|
425
|
+
4. **Battery Usage**: Continuous beacon ranging can consume significant battery. Consider using monitoring (which is more battery-efficient) and only start ranging when needed.
|
|
426
|
+
|
|
427
|
+
5. **UUID Format**: UUIDs must be in the standard format: `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX`
|
|
428
|
+
|
|
429
|
+
6. **Major/Minor Values**: These are optional 16-bit unsigned integers (0-65535) used to identify specific beacons within a UUID.
|
|
430
|
+
|
|
431
|
+
7. **Permissions**: Always request and check permissions before starting beacon operations.
|
|
432
|
+
|
|
433
|
+
## Troubleshooting
|
|
434
|
+
|
|
435
|
+
### iOS Issues
|
|
436
|
+
|
|
437
|
+
**"Beacons not detected" or "Plugin not working"**
|
|
438
|
+
|
|
439
|
+
1. **Verify Info.plist configuration**:
|
|
440
|
+
- Ensure all required keys are present (see Configuration section above)
|
|
441
|
+
- Check that permission descriptions are meaningful and not empty
|
|
442
|
+
|
|
443
|
+
2. **Enable Background Modes in Xcode**:
|
|
444
|
+
- This is a common issue - you MUST enable capabilities in Xcode, not just add Info.plist keys
|
|
445
|
+
- Open `ios/App/App.xcworkspace` in Xcode
|
|
446
|
+
- Select your target → "Signing & Capabilities"
|
|
447
|
+
- Add "Background Modes" capability
|
|
448
|
+
- Check "Location updates" and "Uses Bluetooth LE accessories"
|
|
449
|
+
|
|
450
|
+
3. **Request proper authorization**:
|
|
451
|
+
```typescript
|
|
452
|
+
// For foreground detection only
|
|
453
|
+
await CapacitorIbeacon.requestWhenInUseAuthorization();
|
|
454
|
+
|
|
455
|
+
// For background monitoring (required for region enter/exit events when app is closed)
|
|
456
|
+
await CapacitorIbeacon.requestAlwaysAuthorization();
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
4. **Check Bluetooth is enabled**:
|
|
460
|
+
```typescript
|
|
461
|
+
const { enabled } = await CapacitorIbeacon.isBluetoothEnabled();
|
|
462
|
+
if (!enabled) {
|
|
463
|
+
// Prompt user to enable Bluetooth in Settings
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
5. **Verify authorization status**:
|
|
468
|
+
```typescript
|
|
469
|
+
const { status } = await CapacitorIbeacon.getAuthorizationStatus();
|
|
470
|
+
console.log('Auth status:', status);
|
|
471
|
+
// Should be 'authorized_when_in_use' or 'authorized_always'
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
6. **Check device compatibility**:
|
|
475
|
+
- iBeacon requires iOS 7.0+
|
|
476
|
+
- Some features require specific iOS versions (e.g., ranging in background)
|
|
477
|
+
- Use `isRangingAvailable()` to check device support
|
|
478
|
+
|
|
479
|
+
**"No events firing" or "addListener not working"**
|
|
480
|
+
|
|
481
|
+
- Ensure you set up listeners **before** starting monitoring/ranging:
|
|
482
|
+
```typescript
|
|
483
|
+
// Set up listeners first
|
|
484
|
+
await CapacitorIbeacon.addListener('didEnterRegion', (data) => {
|
|
485
|
+
console.log('Entered:', data.region.identifier);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// Then start monitoring
|
|
489
|
+
await CapacitorIbeacon.startMonitoringForRegion({
|
|
490
|
+
identifier: 'MyRegion',
|
|
491
|
+
uuid: 'YOUR-UUID-HERE'
|
|
492
|
+
});
|
|
493
|
+
```
|
|
388
494
|
|
|
389
|
-
|
|
495
|
+
**Background monitoring not working**
|
|
390
496
|
|
|
391
|
-
|
|
497
|
+
- Requires "Always" authorization: `requestAlwaysAuthorization()`
|
|
498
|
+
- Must have `UIBackgroundModes` with `location` and `bluetooth-central` in Info.plist
|
|
499
|
+
- Must have Background Modes capability enabled in Xcode
|
|
500
|
+
- iOS may throttle background scanning to preserve battery
|
|
392
501
|
|
|
393
|
-
|
|
502
|
+
### Android Issues
|
|
394
503
|
|
|
395
|
-
|
|
504
|
+
See the Android permissions section in the Configuration above. Most Android issues relate to:
|
|
505
|
+
- Not requesting runtime permissions
|
|
506
|
+
- Missing foreground service on Android 8+
|
|
507
|
+
- Bluetooth not enabled
|
|
396
508
|
|
|
397
|
-
|
|
509
|
+
For detailed Android troubleshooting, check the AltBeacon library documentation.
|
|
398
510
|
|
|
399
511
|
## Credits
|
|
400
512
|
|
|
@@ -43,7 +43,7 @@ import org.altbeacon.beacon.Region;
|
|
|
43
43
|
)
|
|
44
44
|
public class CapacitorIbeaconPlugin extends Plugin implements BeaconConsumer {
|
|
45
45
|
|
|
46
|
-
private final String pluginVersion = "8.1.
|
|
46
|
+
private final String pluginVersion = "8.1.11";
|
|
47
47
|
private static final String FOREGROUND_CHANNEL_ID = "beacon_service_channel";
|
|
48
48
|
private static final int FOREGROUND_NOTIFICATION_ID = 456;
|
|
49
49
|
private BeaconManager beaconManager;
|
|
@@ -4,7 +4,7 @@ import CoreLocation
|
|
|
4
4
|
|
|
5
5
|
@objc(CapacitorIbeaconPlugin)
|
|
6
6
|
public class CapacitorIbeaconPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
7
|
-
private let pluginVersion: String = "8.1.
|
|
7
|
+
private let pluginVersion: String = "8.1.11"
|
|
8
8
|
public let identifier = "CapacitorIbeaconPlugin"
|
|
9
9
|
public let jsName = "CapacitorIbeacon"
|
|
10
10
|
public let pluginMethods: [CAPPluginMethod] = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-ibeacon",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.11",
|
|
4
4
|
"description": "iBeacon plugin for Capacitor - proximity detection and beacon region monitoring",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
53
53
|
"clean": "rimraf ./dist",
|
|
54
54
|
"watch": "tsc --watch",
|
|
55
|
-
"prepublishOnly": "npm run build"
|
|
55
|
+
"prepublishOnly": "npm run build",
|
|
56
|
+
"check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"@capacitor/android": "^8.0.0",
|