Use device.injectBeacon() to simulate the device detecting a nearby iBeacon, triggering CLLocationManager callbacks in your app as if real hardware were present. Pushing a .region file triggers a region-entry callback; also pushing a .beacon file triggers ranging callbacks.
See the iOS Device Reference for the full injectBeacon API.
Examples
Region entry and ranging
Region entry only (no ranging)
Omit the beacons array to trigger only a region-entry event.
When to use
- Your app uses iBeacon proximity for retail check-ins, loyalty triggers, or location-based promotions.
- Your app uses indoor navigation or asset tracking via Bluetooth beacons.
- Your app responds to beacon region entry or exit events.
- Your test needs to verify ranging callbacks with specific major/minor values.
Location permissions
iBeacons require location permissions. Two important caveats:
autoAcceptAlerts chooses “Ask Next Time” for location dialogs. If the permission dialog appears, Appium will not choose “Always Allow” — and there is no way to change it after the fact.
Background location access cannot be auto-accepted. If your app requires “Change to Always Allow” for background beacon detection, you must handle the dialog manually using respectSystemAlerts: true:
respectSystemAlerts: true may slow down Appium performance. Use it only when you need to interact with system dialogs manually.
Full sample test