Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions device/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,26 @@ Get the device's current language locale tag.

#### DeviceId

| Prop | Type | Description | Since |
| ---------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`identifier`** | <code>string</code> | The identifier of the device as available to the app. This identifier may change on modern mobile platforms that only allow per-app install ids. On iOS, the identifier is a UUID that uniquely identifies a device to the app’s vendor ([read more](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)). on Android 8+, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)). On web, a random identifier is generated and stored on localStorage for subsequent calls. If localStorage is not available a new random identifier will be generated on every call. | 1.0.0 |
| Prop | Type | Description | Since |
| ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`identifier`** | <code>string</code> | The identifier of the device as available to the app. This identifier may change on modern mobile platforms that only allow per-app install ids. On iOS, the identifier is a UUID that uniquely identifies a device to the app’s vendor ([read more](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)). on Android, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)). On web, a random identifier is generated and stored on localStorage for subsequent calls. If localStorage is not available a new random identifier will be generated on every call. | 1.0.0 |


#### DeviceInfo

| Prop | Type | Description | Since |
| ----------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| **`name`** | <code>string</code> | The name of the device. For example, "John's iPhone". This is only supported on iOS and Android 7.1 or above. On iOS 16+ this will return a generic device name without the appropriate [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name). | 1.0.0 |
| **`model`** | <code>string</code> | The device model. For example, "iPhone13,4". | 1.0.0 |
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | The device platform (lowercase). | 1.0.0 |
| **`operatingSystem`** | <code><a href="#operatingsystem">OperatingSystem</a></code> | The operating system of the device. | 1.0.0 |
| **`osVersion`** | <code>string</code> | The version of the device OS. | 1.0.0 |
| **`iOSVersion`** | <code>number</code> | The iOS version number. Only available on iOS. Multi-part version numbers are crushed down into an integer padded to two-digits, ex: `"16.3.1"` -&gt; `160301` | 5.0.0 |
| **`androidSDKVersion`** | <code>number</code> | The Android SDK version number. Only available on Android. | 5.0.0 |
| **`manufacturer`** | <code>string</code> | The manufacturer of the device. | 1.0.0 |
| **`isVirtual`** | <code>boolean</code> | Whether the app is running in a simulator/emulator. | 1.0.0 |
| **`memUsed`** | <code>number</code> | Approximate memory used by the current app, in bytes. Divide by 1048576 to get the number of MBs used. | 1.0.0 |
| **`webViewVersion`** | <code>string</code> | The web view browser version | 1.0.0 |
| Prop | Type | Description | Since |
| ----------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`name`** | <code>string</code> | The name of the device. For example, "John's iPhone". This is only supported on iOS and Android. On iOS 16+ this will return a generic device name without the appropriate [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name). | 1.0.0 |
| **`model`** | <code>string</code> | The device model. For example, "iPhone13,4". | 1.0.0 |
| **`platform`** | <code>'ios' \| 'android' \| 'web'</code> | The device platform (lowercase). | 1.0.0 |
| **`operatingSystem`** | <code><a href="#operatingsystem">OperatingSystem</a></code> | The operating system of the device. | 1.0.0 |
| **`osVersion`** | <code>string</code> | The version of the device OS. | 1.0.0 |
| **`iOSVersion`** | <code>number</code> | The iOS version number. Only available on iOS. Multi-part version numbers are crushed down into an integer padded to two-digits, ex: `"16.3.1"` -&gt; `160301` | 5.0.0 |
| **`androidSDKVersion`** | <code>number</code> | The Android SDK version number. Only available on Android. | 5.0.0 |
| **`manufacturer`** | <code>string</code> | The manufacturer of the device. | 1.0.0 |
| **`isVirtual`** | <code>boolean</code> | Whether the app is running in a simulator/emulator. | 1.0.0 |
| **`memUsed`** | <code>number</code> | Approximate memory used by the current app, in bytes. Divide by 1048576 to get the number of MBs used. | 1.0.0 |
| **`webViewVersion`** | <code>string</code> | The web view browser version | 1.0.0 |


#### BatteryInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.BatteryManager;
import android.os.Build;
import android.provider.Settings;
Expand Down Expand Up @@ -63,33 +62,14 @@ public boolean isVirtual() {
}

public String getName() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
return Settings.Global.getString(this.context.getContentResolver(), Settings.Global.DEVICE_NAME);
}

return null;
return Settings.Global.getString(this.context.getContentResolver(), Settings.Global.DEVICE_NAME);
}

public String getWebViewVersion() {
PackageInfo info = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
info = WebView.getCurrentWebViewPackage();
} else {
try {
info = getWebViewVersionSubAndroid26();
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
PackageInfo info = WebView.getCurrentWebViewPackage();
if (info != null) {
return info.versionName;
}

return Build.VERSION.RELEASE;
}

private PackageInfo getWebViewVersionSubAndroid26() throws PackageManager.NameNotFoundException {
PackageManager pm = this.context.getPackageManager();
return pm.getPackageInfo("com.android.chrome", 0);
}
}
4 changes: 2 additions & 2 deletions device/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface DeviceId {
*
* On iOS, the identifier is a UUID that uniquely identifies a device to the app’s vendor ([read more](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor)).
*
* on Android 8+, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)).
* on Android, __the identifier is a 64-bit number (expressed as a hexadecimal string)__, unique to each combination of app-signing key, user, and device ([read more](https://developer.android.com/reference/android/provider/Settings.Secure#ANDROID_ID)).
*
* On web, a random identifier is generated and stored on localStorage for subsequent calls.
* If localStorage is not available a new random identifier will be generated on every call.
Expand All @@ -21,7 +21,7 @@ export interface DeviceInfo {
/**
* The name of the device. For example, "John's iPhone".
*
* This is only supported on iOS and Android 7.1 or above.
* This is only supported on iOS and Android.
*
* On iOS 16+ this will return a generic device name without the appropriate [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name).
*
Expand Down
Loading