当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Platform.is方法代码示例

本文整理汇总了TypeScript中@ionic/angular.Platform.is方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Platform.is方法的具体用法?TypeScript Platform.is怎么用?TypeScript Platform.is使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ionic/angular.Platform的用法示例。


在下文中一共展示了Platform.is方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

    this.platform.ready().then(async () => {
      let defaultLanguage;

      if (this.platform.is('ios') || this.platform.is('android')) {
        defaultLanguage = (await this.globalization.getPreferredLanguage()).value.slice(0, 2);
        this.statusBar.styleLightContent();
        this.splashScreen.hide();
      } else {
        defaultLanguage = navigator.language.slice(0, 2);
      }

      // we assume that availableLanguage[0] is default language if user language is not available
      if (environment.availableLanguage && environment.availableLanguage.length > 0) {
        if (environment.availableLanguage.indexOf(defaultLanguage) === -1) {
          defaultLanguage = environment.availableLanguage[0];
        }
      } else {
        // or 'fr' if array is empty
        defaultLanguage = 'fr';
      }

      this.translate.setDefaultLang(defaultLanguage);

      this.settings.loadSettings();
      this.onlineTreks.loadTreks();
    });
开发者ID:makinacorpus,项目名称:Geotrek-mobile,代码行数:26,代码来源:app.component.ts

示例2: resolve

 resolve(route: ActivatedRouteSnapshot): Observable<TreksContext> {
   const offline = !!route.data['offline'];
   const treksService: TreksService = offline ? this.offlineTreks : this.onlineTreks;
   const mapConfig =
     offline && (this.platform.is('ios') || this.platform.is('android'))
       ? environment.offlineMapConfig
       : environment.onlineMapConfig;
   return of({
     treksTool: treksService,
     offline: offline,
     mapConfig,
   });
 }
开发者ID:makinacorpus,项目名称:Geotrek-mobile,代码行数:13,代码来源:treks.resolver.ts

示例3: getDeviceInfo

  /**
   * @name getDeviceInfo
   * @description get information about the device
   */
  getDeviceInfo(): IDeviceInfo {
    if (this.platform.is('cordova')) {
      this.deviceInfo = {
        cordovaVersion: this.device.cordova,
        appVersion: undefined,
        osPlatform: this.device.platform,
        osVersion: this.device.version,
        uuid: this.device.uuid,
        deviceManufacturer: this.device.manufacturer,
        deviceModel: this.device.model
      };

      this.storage.get('appVersion').then(version => {
        this.deviceInfo.appVersion = version;
      });
      return this.deviceInfo;
    } else { return null; }
  }
开发者ID:University-of-Potsdam-MM,项目名称:UP.App,代码行数:22,代码来源:device.service.ts

示例4: handleError

  /**
   * @name handleError
   * @description handles uncaught errors
   * @param error
   */
  handleError(error) {

    let uuid = 'none';
    if (this.platform.is('cordova')) {
      uuid = this.device.uuid;
    }

    if (error instanceof HttpErrorResponse) {
      console.log(`[MobileUPErrorHandler]: Uncaught HTTP error!`);

      let messageI18nKey = `alert.httpErrorStatus.unknown`;
      if (error.status) { messageI18nKey = `alert.httpErrorStatus.${error.status}`; }

      this.alertService.showAlert({
        headerI18nKey: 'alert.title.httpError',
        messageI18nKey: messageI18nKey
      });

      this.logging.logError({
        uuid: uuid,
        url: error.url,
        message: `HttpError ${error.status} occured`
      });
    } else {
      console.log(`[MobileUPErrorHandler]: Uncaught error!`);

      this.alertService.showAlert({
        headerI18nKey: 'alert.title.unexpectedError',
        messageI18nKey: 'alert.unknown_error'
      });

      const caller_line = error.stack.split('\n')[1];
      const index = caller_line.indexOf('at ');
      const cleanedURL = caller_line.slice(index + 2, caller_line.length);

      this.logging.logError({
        uuid: uuid,
        message: `Unexpected error: ${error.message ? error.message : 'no message provided'}`,
        url: cleanedURL
      });
    }

  }
开发者ID:University-of-Potsdam-MM,项目名称:UP.App,代码行数:48,代码来源:errorHandler.ts


注:本文中的@ionic/angular.Platform.is方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。