Location>code7788 >text

Geo-fencing, creating new boundaries for smart living

Popularity:186 ℃/2024-09-03 11:13:06

With the popularity of smartphones and other mobile devices, the user demand for location-based access to personalized services has increased dramatically, for example, the user enters the scope of the shopping district and stays in the operation for a period of time, intelligent triggering to the user to push the shopping district to eat, drink, play, and enjoy the preferential activities of the news; and also when the user arrives at the airport of the very resident triggers the fence, to push to the user to ask whether they need to book a hotel near the airport of the news! In addition, when the user arrives at the airport, the fence will be triggered to send a message to the user asking whether he/she needs to book a hotel near the airport, thus providing the user with the first insight into his/her potential needs and providing relevant services.

Most of the third-party push message service providers in the market today usually can't pinpoint the push range to a certain business district or a smaller area. HarmonyOS SDKlocation service(Location Kit)Geo-fencing technologyIt can be a good way to make up for this deficiency.

Geo-fencing is the use of a virtual fence to enclose a virtual geographic boundary, so that when the phone enters, leaves, or moves within this enclosed specific geographic area, the phone can automatically receive notification and warning messages. By combining geo-fencing and push messaging, accurate push messaging can be realized for people in a specific area.
image

For example, when the target audience walks into the vicinity of a shopping district, a life services App will push them "a number of restaurants in the shopping district is on sale, click to view the details of the offer" message, so that you can push the user in a timely manner and their current location and demand for information related to the increase in the user's willingness to buy. Geo-fencing technology can help the app to more accurately locate the target users and improve the accuracy and effect of the push.

Geofencing technology also provides more precise targeting capabilities. For example, in security monitoring, fences can be set up to set up activities within a specific area to enhance security monitoring and emergency response. In industry scenarios, for the logistics and transportation industry, it can be used to track the location of goods in the transportation process, to remind or notify the relevant personnel of the arrival or departure of goods; with the rise of smart cities and IoT technology, geo-fencing technology has also been widely used in the fields of city management, intelligent transportation, and environmental monitoring.

image

Functional Advantages

System level fencing with low fence power consumption

App hibernation can still wake up directly, fence detection process resident, avoid being affected by background applications

Fence range: supports a radius of 200 meters to 10 kilometers

Customized Fence Detection

Unlimited number of fences and direct selection of business district fences

development step

1. To use the geo-fencing function, you need to have the permission .APPROXIMATELY_LOCATION, the method and steps of location permission application seeApply for Location Permission Development Guidelines

2. Import geoLocationManager module, wantAgent module and BusinessError module.

import { geoLocationManager } from '@';
import { wantAgent } from '@';
import { BusinessError } from '@'

3. Create WantAgentInfo information.

Scenario 1: Create WantAgentInfo information that pulls up Ability.

let wantAgentObj:_wantAgent|null = null; // Used to save the successfully created wantAgent object, which is subsequently used to complete the triggered action.

// Set the action type via WantAgentInfo's operationType.
let wantAgentInfo: = {
    wants: [
        {
            deviceId: '',
            bundleName: '',
            abilityName: 'EntryAbility',
            action: '',
            entities: [],
            uri: '',
            parameters: {}
        }
    ],
    operationType: .START_ABILITY,
    requestCode: 0,
    wantAgentFlags: [.CONSTANT_FLAG]
}.

Scenario 2: Create WantAgentInfo messages that publish public events.

let wantAgentObj:_wantAgent|null = null; // Used to save the successfully created WantAgent object, which is subsequently used to complete the triggered action.

// Set the action type via WantAgentInfo's operationType.
let wantAgentInfo: = {
    wants: [
        {
            action: 'event_name', // set the event name
            parameters: {}, // set event name
        }
    ], }
    operationType: .SEND_COMMON_EVENT, requestCode: 0, }, }, }, }, }, }, }, }, }, }, }, }
    requestCode: 0,
    wantAgentFlags: [.CONSTANT_FLAG], }
}

4. Call the getWantAgent() method to create the WantAgent.

And after getting the WantAgent object, call the geofence interface to add a fence, when the device enters or exits the fence, the system will automatically trigger the WantAgent action.

// establishWantAgent
(wantAgentInfo, (err, data) => {
    if (err) {
      ('getWantAgent err=' + (err));
      return;
    }
    ('getWantAgent success');
    wantAgentObj = data;
    let requestInfo: = {'scenario': 0x301, "geofence": {"latitude": 31.12, "longitude": 121.11, "radius": 100, "expiration": 10000}};
    try {
        ('gnssFenceStatusChange', requestInfo, wantAgentObj);
    } catch (err) {
        ("errCode:" + (err));
    }
});

Note: Currently, only circular fences are supported and rely on the GNSS chip's geo-fencing feature to accurately recognize user entry and exit fence events only in outdoor open areas.

In summary, geofencing technology has important applications in the field of intelligent and location-based services. It is not only a powerful tool for developers to improve service accuracy and user experience, but also to optimize resource management and create new business value and solutions.

Learn more >>

interviewsLocation Services Alliance Official Website

gainLocation Services Development Guidance Document