deviceinfo.js 794 Bytes
Newer Older
Kim Peace committed
1 2 3 4 5 6 7 8 9 10 11
NativeBridgeDataSource.getDeviceInfo = function () {
  if (typeof android != "undefined") {
    return JSON.parse(android.getDeviceInfo());
  } else {
    return JSON.parse(callNativeApp(NATIVE_KEY_IOS.getDeviceInfo, {}));
  }
};

var DeviceInfo = class {
  isMoble; // iphone or iPad
  platform; // ios or android
12
  androidVersion;
Kim Peace committed
13 14 15 16

  constructor(deviceInfo) {
    this.isMoble = deviceInfo.isMoble;
    this.platform = deviceInfo.platform;
17 18 19
    if (typeof android != "undefined") {
      this.androidVersion = android.getAndroidVersion();
    }
Kim Peace committed
20
  }
21 22 23 24 25 26 27 28 29 30 31 32

  isiOS() {
    return this.platform == "ios";
  }

  isAndroid() {
    return this.platform == "android";
  }

  isMobile() {
    return this.isMoble == "true";
  }
Kim Peace committed
33 34 35
};

var deviceInfo = new DeviceInfo(NativeBridgeDataSource.getDeviceInfo());