Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LocationGeofenceService

en

class for location geofence

zh

地理围栏处理相关类

Hierarchy

  • HMSBaseService
    • LocationGeofenceService

Index

Constructors

constructor

Properties

Static StatusCode

StatusCode: LocationStatusCode = LocationStatusCode

Methods

createGeofenceList

  • en

    adds multiple geofences

    zh

    创建地理围栏

    example
    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);
    

    Parameters

    Returns void

off

  • off(event_name: string, callback: Function, target: any): void
  • en

    remove event listener

    zh

    取消事件的监听

    example
    huawei.hms.location.locationActivityService.off(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => {
        //TODO
    }
    

    Parameters

    • event_name: string

      event name

    • callback: Function

      callback function

    • target: any

      target node

    Returns void

on

  • on(event_name: string, cb: Function, node?: any): void
  • en

    event listener

    zh

    持续监听事件

    example
    huawei.hms.location.locationActivityService.on(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_ACTIVITY_UPDATES, (result) => {
        //TODO
    }
    

    Parameters

    • event_name: string

      event name

    • cb: Function

      event callback

    • Optional node: any

      target node

    Returns void

once

  • once(event_name: string, cb: Function, node?: any): void
  • en

    event listener for once

    zh

    监听一次事件

    example
    huawei.hms.location.locationActivityService.once(huawei.hms.location.HMS_LOCATION_EVENT_LISTENER_NAME.HMS_DELETE_ACTIVITY_IDENTIFICATION_UPDATES, (result) => {
        //TODO
    }
    

    Parameters

    • event_name: string

      event name

    • cb: Function

      event callback

    • Optional node: any

      target node

    Returns void

removeWithID

  • removeWithID(idList: Array<string> | any): void
  • en

    remove the geofence by id

    zh

    根据地理围栏id列表删除地理围栏

    example
    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);
    

    Parameters

    • idList: Array<string> | any

    Returns void

removeWithIntent

  • removeWithIntent(): void
  • en

    remove the geofence with intent

    zh

    移除当前intent的地理围栏

    example
    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();
    

    Returns void

targetOff

  • targetOff(target_node: any): void
  • en

    remove all event listener for the node

    zh

    取消某个节点所有的事件监听

    example
    huawei.hms.location.locationService.targetOff(this);
    

    Parameters

    • target_node: any

    Returns void

Generated using TypeDoc