Official Content

The Client Information API is a set of functions intended to provide access to the client machine information, where the application is running. The 'Client machine' could be:

  • A Smart Device running an App
    Applications running on Native Mobile Generator usually require some information on the device such as its identification, phone number, etc. 
  • Browser runinng a Web application

ClientInformation API Structure

Scenario

A company provides its sales representatives with a smart device (iPhone, iPad, Android phone or tablet, etc.) to enter purchase orders, check customer information, etc. The IT department decides that no user authentication will be required except for the device identification each one has been assigned. If further authentication methods are required, GeneXus Access Manager (GAM) should be used.

Code example

1. Create a Procedure object named GetClientInfo.

This procedure saves all the required identification information.

New
      UserId =  &ClientInformation.Id
      UserLastConnection = Now() // Another option to insert this value is to configure the default rule with this value.
  when duplicate
      For each
          UserLastConnection = Now()
      EndFor
EndNew

2. Define a variable of "clientInformation" type.

A typical use case is to obtain information on the device (for example, its ID or operating system) from which the client is accessing our application.

For example, in the list of a Work With pattern and Work With object you can program the following:

Start Event
    Composite
        GetClientInfo.Call()
    EndComposite
EndEvent

 

Note: In case the NetworkID method is used, the generator property Send Device Information on Requests must be true.

Send Device Information on Request Property in True

ClientInformation API Properties

ClientInformation.Id

This property returns an acceptable device identifier in most implementations. Please read ClientInformation.Id Property for detailed behavior description.

ClientInformation.OSName Returns the operating system name running on the SD as a string (VarChar(40)).

Returned values are: "iPad", "iPhone", "iPod", "Android" and "Blackberry".

ClientInformation.OSVersion Returns the version of the operating system running on the Smart Devices as a string (VarChar(40)).

The returned value format depends on the operating system.

ClientInformation.NetworkId

The value of this method is valid only for Smart Devices. It is used to identify a smart device that is accessing the network, and its value depends on the network technology.

A unique identifier for the device is returned, which can be IMEI, MEID, ESN or null if the device ID is not available.

The network identifier must be used only in special circumstances, because it is considered as “personal information” in some platforms. This value is not reliable when used in devices other than phones.

Note: This property is not supported in Apple platform because it’s not possible to access this data through code (Apple doesn’t approve applications that do so).
ClientInformation.Language

A character string is returned with the device language.

Possible use cases: For statistical purposes, for example, to measure the number of devices accessing the application that lack the language configuration not provided by the application. In this way, priorities can be established to make the application international.

The returned string syntax is <Language>-<Region>,<Language> ; following W3C standards: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

For example:

Event Start
     … 
    &CharType = &ClientInformation.Language
     …
EndEvent

…a possible value of &ChartType could be:

en-US,en

Note that the application will be automatically displayed in the language more appropriate for the user, depending on the device language and the languages available on the Knowledge Base. The GetLanguage function must be used to programmatically determine the language being used to display the application.
ClientInformation.DeviceType 

Returns one of the following enumerated values from SmartDeviceType domain:

iOS = 0, Android = 1, Blackberry =2, WPhone = 3

Available from X Evolution 3 Upgrade 7. 

 

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