Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to identify from the user-agent if a Huawei device is NOT supporting google services?

I would like to check in my Google Analytics how big a proportion of my user base is using Huawei devices which are no longer using google services but instead using App Gallery etc.

I was wondering if I could e.g. look for specific OS versions in the User-Agents etc.?

like image 230
Niels Kristian Avatar asked Oct 14 '22 23:10

Niels Kristian


1 Answers

If I read your question correctly, you are looking for ways to detect Huawei devices that are not Google supported, meaning Huawei devices without Google Mobile Services (aka Google Play Services, or GMS).

To detect these particular devices, you need to first obtain Huawei device model number list released after May 2019, these generally include Mate 30, 40, P40 series. You can get the list from here (sort by Time of release).

Get Huawei device model through the following methods, then check it against the non-GMS Huawei device list that you have built.

  • Android app – Implement Firebase Analytics to detect and report device model. You can also try Huawei Analytics Kit.

  • Web host (since you mentioned ‘user-agent’) – Huawei device browsers report HMS and device model number in user-agent header and your web host can pick it up. Here is an example of user-agent reported by Huawei Mate 30 Pro (model # LIO-AL00):

    a. Huawei Browser – Mozilla/5.0 (Linux; Android 10; LIO-AL00; HMSCore 5.0.4.301) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 HuaweiBrowser/11.0.4.300 Mobile Safari/537.36

    b. Google Chrome – Mozilla/5.0 (Linux; Android 10; LIO-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.114 Mobile Safari/537.36

If you just need to determine if certain devices don’t have Google Play Services, you can make use of this API:

public int isGooglePlayServicesAvailable (Context context)

Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.

Returns

• status code indicating whether there was an error. Can be one of following in ConnectionResult: SUCCESS, SERVICE_MISSING, SERVICE_UPDATING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID

If the result is SERVICE_MISSING, then create a custom event in Firebase Analytics and report it with device model. This is a sure way to determine if the device has not Google Play Services.

like image 54
Zinna Avatar answered Oct 21 '22 04:10

Zinna