ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Beacon functions
  • Necessary version
  • Bluetooth Low Energy
  • Required permissions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Used to find the Beacons near the device.
Example
// Dans un musée, on souhaite afficher sur l'appareil du visiteur les informations 
// sur l'oeuvre qu'il est en train de regarder. On associe à chaque balise Beacon 
// le même UUID correspondant au musée et des numéros Major et Minor 
// permettant d'identifier chaque balise de manière unique. 
// On dispose une balise Beacon à côté de chaque oeuvre du musée. 
// L'application doit appeler la fonction BeaconDétectePrécis avec une variable 
// BeaconGroupe correspondant aux balises du musée. 
// La procédure callback passée en paramètre à la fonction sera appelée à chaque fois 
// qu'une nouvelle liste de balises Beacon sera détectée. Il suffit ensuite de trouver 
// la balise la plus proche pour en déduire l'oeuvre que regarde le visiteur et afficher 
// les informations correspondantes dans l'application.

// UUID du musée
sUUID is string = "f4231ab6-5ef2-6c99-4229-af6c72e0446e"
// Création d'une variable beaconGroupe correspondant aux balises du musée
groupeMusée is beaconGroup
groupeMusée.UUID = sUUID
// Lancement de la détection
BeaconDetectPrecise(groupeMusée, ProcDétection)
INTERNAL PROCEDURE ProcDétection(tabInfo is array of beaconDetectionInfo)
	nDistanceMin is int 
	BaliseLaPlusProche is beaconDetectionInfo
	FOR EACH Information OF tabInfo
		IF nDistanceMin = 0 _OR_ Information.Distance < nDistanceMin
			BaliseLaPlusProche = Information
		END
	END
	// Affichage des informations sur l'oeuvre associée à la balise
	AfficheInfoOeuvre(BaliseLaPlusProche.Major, BaliseLaPlusProche.Minor)
END
Syntax
<Result> = BeaconDetectPrecise(<Group of Beacons> , <WLanguage procedure>)
<Result>: Boolean
  • True if the detection was started,
  • False otherwise. To get more details on the error, use ErrorInfo.
<Group of Beacons>: beaconGroup variable
Name the of beaconGroup variable that describes the searched group of Beacons.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called when a new list of Beacons is detected.
This procedure has the following format:
PROCEDURE <Procedure Name>(<Array of Detection Info>)
where <Array of detection info> is a beaconDetectionInfo variable that describes the information about the detected Beacons (identifiers, Major/Minor numbers, distance, etc.)
Remarks
  • This function thoroughly studies Bluetooth emissions around the device to detect Beacons and to estimate how far they are. This analysis is energy-intensive: we therefore recommend calling this function only if at least one tag in the group is nearby.
    To do so, you can call BeaconDetectBackground then BeaconDetectPrecise from the callback procedure run when the application detected the entry in the Beacon transmission range.
    Furthermore, we advise you to stop the precise detection as soon as possible. The BeaconStopPreciseDetection function is used to stop detection in progress: for example, it can be called in the WLanguage procedure executed when the application has detected the exit of the group's tags from the emission zone.
  • The precise detection of Beacons is performed only when the application is in the foreground. When the application goes into background, the detection is automatically suspended and it will resume as soon as the application goes back into foreground. The detection is permanently stopped when the application is stopped. To perform a detection in background, use BeaconDetectBackground.
  • iPhone/iPadIOS WidgetMac Catalyst When generating the application, you can allow BeaconDetectPrecise to be called when the application is in the background (option "Allow calling GPSFollowMovement and BeaconDetectPrecise when the application is in the background" in the "Configuration" step of the wizard).. In this case, the precise detection can continue when the application is in background or when the device is in stand-by mode. For more details, see Generating an iOS application.
  • Several precise detections cannot be started at the same time. If BeaconDetectPrecise is called while a detection is already in progress, the current detection will be stopped and a new detection will be started.

Necessary version

AndroidAndroid Widget Beacon functions are only available on Android 4.3 or later (API level 18).
A fatal error occurs if the function is used with an earlier system version.
To determine the version of Android the application is running on, use SysAndroidVersion.
iPhone/iPadIOS Widget Beacon functions are only available on iOS11 or later.
AndroidAndroid Widget

Bluetooth Low Energy

The device must support the Bluetooth Low Energy technology (Bluetooth LE).
AndroidAndroid Widget

Required permissions

This function changes the permissions required by the application.
Permission required: ACCESS_COARSE_LOCATION: Allows the application to obtain the approximate position of the device.
Android 11 specific case: This function requires the ACCESS_BACKGROUND_LOCATION permission to access the device's location.
This permission allows using the function when the application is in the background.
If the application needs to use background location:
  • Manually add the "ACCESS_BACKGROUND_LOCATION" permission in the Android application generation wizard.
  • Explicitly request background location permission with PermissionRequest. For example:
    PermissionRequest(permBackgroundLocation, Callback)
    INTERNAL PROCEDURE Callback(p is Permission)
    	IF p.Accordé THEN
    		// Utilisation possible des fonctions nécessitant la localisation en arrière-plan
    	END
    END
A window allows users to:
  • allow access to the device location while the application is in the background,
  • allow access to the location only while the application is in use,
  • deny access to the location. The user can also change these permissions at any time in the Android settings.

Remarks:
  • Follow Google's guidelines for applications that require background location access. For more details, see https://support.google.com/googleplay/android-developer/answer/9799150. If these conditions are not met (especially user information requirements), applications may not be accepted for publication on Google Play.
  • The background location permission should only be requested if the location permission has been granted. Otherwise, PermissionRequest will fail.
  • If the option chosen by the user for the background location access request is more restrictive than the option chosen for the location access request, the application will be automatically restarted.
  • On devices running Android 10 or earlier, if location permission has been granted to the application, the background location permission will be granted without displaying a window.
Component: wd300android.aar
Minimum version required
  • Version 23
Comments
Click [Add] to post a comment

Last update: 03/25/2025

Send a report | Local help