iOS's ID For Advertising can be retrieved at any point with
var advertisingId = NativeEssentials.Instance.AdvertisingId;
Note: See iOS Features page for IDFV retrieval
GAID retrieval is automatically triggered at startup. you can subscribe to be notified when retrieval is complete by using the following callback, and declaring it as early as possibe in your application lifecycle (we recommend the Awake
method).
NativeEssentials.OnGoogleAdvertisingIdRetrieved += (gaid) =>
{
Debug.Log(string.Format("[Info] Retrieved Google Advertiser ID as: {0}", gaid));
};
If you wish to retrieve it at any other point, it should will be available via
var advertisingId = NativeEssentials.Instance.AdvertisingId;
Note: In order to retrieve the GAID, you will need to include Google Play Game Service in ypur project.
The native app version can be retrieved on both iOS and Android with:
var version = NativeEssentials.Instance.VersionNumber;
Note: The value retrieve will be versionName
for Android, and CFBundleShortVersionString
for iOS.
The native app build number can be retrieved on both iOS and Android with:
var buildNumber = NativeEssentials.Instance.BuildNumber;
Note: The value retrieved will be versionCode
for Android, and CFBundleVersion
for iOS.
The native bundle ID can be retrieved on both iOS and Android with:
var bundleId = NativeEssentials.Instance.BundleIdentifier;
Note: The value retrieved will be package
for Android, and CFBundleIdentifier
for iOS.
NativeEssentials can accurately determine if your game is running on tablet or phone. Use the following to return either a string value of phone
or tablet
.
var deviceFamily = NativeEssentials.Instance.DeviceFamily;
With NativeEssentials, you can schedule a local notification with the native iOS, for delivery in the future. This is possible on both iOS and Android calling the following method:
NativeEssentials.Instance.ScheduleLocalNotification("Notification title", "notification body", 90);
Notes:
You can display native alerts on both iOS and Android by invoking the following command:
DialogConfig dialogConfig = new DialogConfig(dialogTitle: "Important!",
dialogMessage: "This is a great game",
yesBtnLabel: "Yes",
noBtnLabel: "No");
NativeEssentials.Instance.ShowNativeAlert(dialogConfig);
For displaying a single button, simply pass an empty string to for the noBtnLabel
parameter of 'DialogConfig`, e.g.:
DialogConfig dialogConfig = new DialogConfig(dialogTitle: "Important!",
dialogMessage: "This is a great game",
yesBtnLabel: "Okay",
noBtnLabel: string.Empty);
If you wish to be notified of the players selection, register the following callback prior to invoking NativeEssentials.Instance.ShowNativeAlert
. Note that the callback parameter will be a bool
indicating if a positive or negative selection was made by the player:
NativeEssentials.OnAlertCallback += (positiveResponse) =>
{
Debug.Log(string.Format("[Alert] Got alert feedback - has positive response: {0}", positiveResponse));
};
In some cases, it might be useful during development to trigger a native crash that is not managed by Unity. You can do this on both iOS and Android with:
NativeEssentials.ForceNativeException();