addGeofence method
- TencentGeofence fence
添加围栏。
Platforms:
- 🅰️ Android:支持
- 🍏 iOS:支持
- 🔶 Harmony:仅支持圆形围栏(TencentGeofence 为 polygon / district 时
抛出
TencentLocationError(错误码unsupportedOnThisPlatform))
Parameters:
fence:围栏定义,包含唯一 ID、类型、坐标、半径、监听事件等参数。
Returns:
- 返回仅表示围栏已提交给 SDK。district(行政区)围栏为异步创建:提交后
SDK 需要网络请求行政区边界,创建完成后通过 onGeofenceCreated 通知,
失败时通过 onError 通知(错误码
geofenceDistrictNotFound/geofenceInvalidRegion,可用 TencentLocationError.details 的geofenceId定位对应围栏)。circle / polygon 为同步添加,不受此影响。
Throws:
失败时抛出 TencentLocationError,可能的错误码:
geofenceDuplicateId / geofenceInvalidRegion / geofenceLimitExceeded /
geofenceNetworkFailed / geofenceDistrictNotFound /
unsupportedOnThisPlatform。
Implementation
Future<void> addGeofence(TencentGeofence fence) =>
_after(() => _platform.addGeofence(_id, fence));