Official Content

The Network external object allows you to check the devices' network status in order to have more information to take some actions. This API is often used in Offline Native Mobile applications to determine the best moment to perform a synchronization.

This external object must be used in a Client-side Event (like the ClientStart event) because it is executed on the user's device and not on the server. Errors may occur if you use it in Server-side Events.

image_201861291110_1_png NetworkExoStruc_20194315156_1_png

Properties

ApplicationServerURL

It is a read-only property set automatically with the Services URL property of the Smart Devices Generator.
The property is then used by several methods explained below.

Methods

IsServerAvailable method

Returns True if the device can access the specified server; otherwise, it returns False. It checks if a package can be routed to the desired URL host; note that no request is made to the current host. The server can be passed as an optional parameter in its URL. If the URL parameter is not present then the method will check the connection to the server URL of the property ApplicationServerURL.

Return value Boolean
Parameters [ Url:URL ]

Type method

Gets the connection type that the device has to a specific server. There are some servers that are only accessed by local networks.

Return value NetworkAPIConnectionType
Parameters [ Url:URL ]

TrafficBasedCost method

Returns true or false depending on whether the connection between the device and the server could cause a monetary cost to the device user.

Return value Boolean
Parameters
  [ Url:URL ]

SetApplicationServerURL

It allows you to change the application URL dynamically. To do so, set the Dynamic Services URL property to True.

Return value None
Parameters [ Url:URL ]

Note: In iOS it is available as of GeneXus 16 upgrade 3, and in Android as of GeneXus 16 upgrade 7.

Events

NetworkStatusChanged event

Notifies when the network status changes.

Input None
Output None

Domains

NetworkAPIConnectionType domain

This domain is defined to identify the device's connection type.
It is based on Numeric(1) with the following enumerated values:

None No connection.
Wifi Wi-Fi connection.
WAN WAN connection.

Scope

Generators: AndroidApple

See Also

Coding your Data Synchronization programs
Manual Synchronization Code Sample

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant