midgithub/unity-sdk-device-utils

Device utils to retrieve device info and set system attributes.

★ 0Forks 2C#GitHub ↗Compare

README

Device Utils for Unity

Requirements

  • Unity 5.3+
  • iOS 8.0+
  • Android API level 16+

Table of Contents

Integration

Import the SDK package funplus-unity-sdk-device-utils-<version>.unitypackage to your project.

The FunPlus SDK is structured in this way:

Assets/
└── FunPlus/
    └── DeviceUtils/
        ├── Editor/
        ├── Example/
        └── Plugins/
            ├── Android/
            └── iOS/

The Example directory is not necessarily a part of the SDK. You can choose not to import it to your project.

For Android Project Only

FunPlus SDK uses the Google Advertising ID to uniquely identify devices. To allow the SDK to use the Google Advertising ID, you must integrate the Google Play Services.

Usage

To call methods provided by DeviceUtils, the first step is to import its namespace to your source files:

using FunPlus.DeviceUtils;

Get Play Advertising ID (Android Only)

This method might return null.

string playAdId = DeviceUtils.GetPlayAdId ();

Get Android ID (Android Only)

string androidId = DeviceUtils.GetAndroidId ();

Get Identifier for Vendor (iOS Only)

This method might return null.

string idfv = DeviceUtils.GetIdentifierForVendor ();

Get Advertising Identifier (iOS Only)

This method might return null.

string idfa = DeviceUtils.GetAdvertisingIdentifier ();

Get System Name

string systemName = DeviceUtils.GetSystemName ();

Get System Version

string systemVersion = DeviceUtils.GetSystemVersion ();

Get Device Model Name

string modelName = DeviceUtils.GetModelName ();

Get Device Manufacturer (Android Only)

string manufacturer = DeviceUtils.GetManufacturer ();

Get Android API Level (Android Only)

string androidApiLevel = DeviceUtils.GetAndroidApiLevel ();

Get App Name

string appName = DeviceUtils.GetAppName ();

Get App Version

string appVersion = DeviceUtils.GetAppVersion ();

Get App Display Language

This method gets the display language for the application, it might be different from the device language.

string appLanguage = DeviceUtils.GetAppLanguage ();

Get Network Carrier Name

string carrier = DeviceUtils.GetNetworkCarrierName ();

Get Screen Brightness

This method returns an integer ranged from 0 to 255 inclusively.

int brightness = DeviceUtils.GetScreenBrightness ();

Set Screen Brightness

For Android project, add the following permission declaration before the application tag in your AndroidManifest.xml if they're not present already.

<uses-permission android:name="android.permission.WRITE_SETTINGS"/>

Note that on Android 6.0+, it will return false and lead the user to a window that requests the WRITE_SETTINGS permission for the first time this method is called.

Value of the brightness parameter should be between 0 and 255. values less than 0 will be treat as 0, and values greater than 255 will be treat as 255.

int brightness = 120;
bool isSuccess = DeviceUtils.SetScreenBrightness (brightness);

Contributors

yuankunzhang

Issues