Thursday, May 12, 2016

Determine if device is an Amazon/Fire TV in Unity 3D

Often when you use the same apk for google play and amazon stores and you need to determine at run time whether your device is running Android OS or a Kindle on Fire OS. You may need to even further determine if the device is an Amazon Fire TV or Android TV app.

In Unity3D you can often use SystemInfo.deviceModel, and put it into if/then or case and set appropriate flags. Then you can implement google play, game circle, forward to the appropriate store for rating an app, etc.:

public static string getDevice() {
if (  SystemInfo.deviceModel.ToLower().Contains("aftb")) {
isAmazon = true;
return "Fire TV";
}
        if (  SystemInfo.deviceModel.ToLower().Contains("amazon")) {
isAmazon = true;
return SystemInfo.deviceModel;
}
isAmazon = false;
return SystemInfo.deviceModel;
}

No comments:

Post a Comment