class for location geofence
地理围栏处理相关类
adds multiple geofences
创建地理围栏
huawei.hms.location.locationGeofenceService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_CREATE_GEOFENCE_LIST, (result) => { if (result.code === huawei.hms.location.locationActivityService.StatusCode.success) { cc.log('createGeofenceList...', 'success'); } else { cc.log('createGeofenceList...', 'fail:', result.errMsg); } }); let cls = huawei.hms.location.GeofenceData; let type = huawei.hms.location.GEOFENCE_TYPE; let list = [ new cls( "msg123456", //setUniqueId type.DWELL_GEOFENCE_CONVERSION | type.ENTER_GEOFENCE_CONVERSION | type.EXIT_GEOFENCE_CONVERSION, //setConversions 24.4813889, //setRoundArea, latitude 118.1590724, //setRoundArea, longitude 2000, //setRoundArea, radius 60 * 60 * 1000, //setValidContinueTime 1000) //setDwellDelayTime ]; let requestType = huawei.hms.location.HMS_LOCATION_GEOFENCEREQUEST; let initType = requestType.EXIT_INIT_CONVERSION | requestType.ENTER_INIT_CONVERSION | requestType.DWELL_INIT_CONVERSION; cc.log('createGeofenceList...', 'params=', JSON.stringify(list), 'init type=', initType); huawei.hms.location.locationGeofenceService.createGeofenceList(list, initType);
geofence data list
remove event listener
取消事件的监听
huawei.hms.location.locationActivityService.off(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => { //TODO }
event name
callback function
target node
event listener
持续监听事件
huawei.hms.location.locationActivityService.on(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => { //TODO }
event callback
event listener for once
监听一次事件
huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_DELETE_ACTIVITY_IDENTIFICATION_UPDATES, (result) => { //TODO }
remove the geofence by id
根据地理围栏id列表删除地理围栏
huawei.hms.location.locationGeofenceService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_REMOVE_GEOFENCE_WITH_ID, (result) => { if (result.code === huawei.hms.location.locationActivityService.StatusCode.success) { cc.log('removeWithID...', 'success'); } else { cc.log('removeWithID...', 'fail:', result.errMsg); } }); var removeID = "ID1"; huawei.hms.location.locationGeofenceService.removeWithID(removeID);
remove the geofence with intent
移除当前intent的地理围栏
huawei.hms.location.locationGeofenceService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_REMOVE_GEOFENCE_WITH_INTENT, (result) => { if (result.code === huawei.hms.location.locationActivityService.StatusCode.success) { cc.log('removeWithIntent', 'success'); } else { cc.log('removeWithIntent...', 'fail:', result.errMsg); } }); huawei.hms.location.locationGeofenceService.removeWithIntent();
remove all event listener for the node
取消某个节点所有的事件监听
huawei.hms.location.locationService.targetOff(this);
Generated using TypeDoc
class for location geofence
地理围栏处理相关类