Contents

1 Enabling the API for searching for nearby ibeacon devices

2 Disabling the API for searching for nearby ibeacon devices

3 API for listening on nearby ibeacon devices

API Description

The "Get Device Info on H5 Pages" JS APIs are designed to extend the application scenarios of WeChat Shake Nearby, enabling developers to search for nearby Beacon signals by accessing WeChat JS-SDK on their H5 applications. You need to group the devices before calling this API because WeChat app only returns the device information already in the group. For the method of grouping devices, see the API description related to the above group.

The "Get Device Info on H5 Pages" JS APIs includes three APIs: startSearchBeacons, stopSearchBeacons, and onSearchBeacons. Only WeChat 6.2.5 or higher are allowed to use WeChat JS-SDK to call these APIs. The Official Account calling the API must be the same as the Official Account that created the group. Introduce the following JS file in the page that needs to call the JS API (supports HTTPS): http://res.wx.qq.com/open/js/jweixin-1.1.0.js, JS-SDK Description Documentation.

Enabling the API for Searching for Nearby ibeacon Devices

API Description

Searches for nearby devices. The purpose is to provide merchants with certain development capabilities with an API to find their own nearby devices. On the webpage accessed by WeChat built-in browser, the JS code can be used to search for the nearby device around the merchant, so that the merchant can use this API to check whether there is a device nearby. When WeChat app detects a device with a signal, it will return the device information. The time interval is 1s. Both android and iOS apps return the detected device information in batches.

API Request Format

Example:
wx.startSearchBeacons({
   ticket:"",
   complete:function(argv){
   //Callback function
   }
});

Parameters

Parameter Required Description
ticket No The business ticket of WeChat Shake Nearby. The system automatically adds it to the page link that is popped up via Shake Nearby.

Response

Successfully enabled, then return:"startSearchBeacons:ok";

If it is already enabled without stopping, it will return:"startSearchBeacons:already started";

If Bluetooth is not enabled, return:"startSearchBeacons:bluetooth power off";

If the geographic location service is not enabled, return:"startSearchBeacons:location service disable";

If the system is not supported, return:"startSearchBeacons:system unsupported".

Disabling the API for Searching for Nearby ibeacon Devices

API Description

Disables the API for searching for nearby devices.

API Request Format

Example:
wx.stopSearchBeacons({
   complete:function(res){
   //Callback function
   }
});

Response

Successfully disabled, then return:"stopSearchBeacons:ok";

API for Listening on Nearby ibeacon Devices

API Description

The onSearchBeacons API for listening on nearby devices is called back after the startSearchBeacons API is enabled. This API returns the relevant nearby devices registered by the merchant.

API Request Format

Example:
wx.onSearchBeacons({
   complete:function(argv){
   //Callback function
   }
});

Response

onSearchBeacons:
{
   "beacons":[
           	{
           	"major":10008,
           	"minor":57686,
           	"uuid":"FDA50693-A4E2-4FB1-AFCF-C6EB07647825",
           	"accuracy":"0.235344",
           	"rssi":"-66",
           	"proximity":"1",
           	"heading":"288.1355"
           	},
           	{
           	"major":10008,
           	"minor":57687,
           	"uuid":"FDA50693-A4E2-4FB1-AFCF-C6EB07647825",
           	"accuracy":"0.349124",
           	"rssi":"-49",
           	"proximity":"2",
           	"heading":"288.1355"
           	}
           	]
}

Parameters

Parameter Description
UUID, major, minor UUID, major, minor
accuracy Distance, in meters
proximity Precision, 0: CLProximityUnknown, 1: CLProximityImmediate, 2: CLProximityNear, 3: CLProximityFar
rssi Strength of the received signal
heading The direction of the device when receiving the signal (Android devices will return this field, and iOS devices will not); HTML5 standard API can be used for iOS devices to obtain the direction if necessary. View example