當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular.Platform類代碼示例

本文整理匯總了TypeScript中@ionic/angular.Platform的典型用法代碼示例。如果您正苦於以下問題:TypeScript Platform類的具體用法?TypeScript Platform怎麽用?TypeScript Platform使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Platform類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2:

    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

示例3: initializeApp

 initializeApp() {
     this.platform.ready().then(() => {
         // Okay, so the platform is ready and our plugins are available.
         // Here you can do any higher level native things you might need.
         this.statusBar.styleDefault();
         this.splashScreen.hide();
     });
 }
開發者ID:nickp10,項目名稱:DFSStats,代碼行數:8,代碼來源:app.component.ts

示例4: exportCSV

 exportCSV() {
   this.platform.ready().then(readySource => {
     this.storage.getList().then(favList => {
       const file = `data:text/csv;charset=utf8,${json2csv.parse(favList)}`;
       this.export(file, 'csv', readySource);
     })
   })
 }
開發者ID:PierrePlessy,項目名稱:pple_ultimateMovie,代碼行數:8,代碼來源:download.service.ts

示例5: exportJSON

 exportJSON() {
   this.platform.ready().then(readySource => {
     let file = 'data:text/json;charser=utf8,';
     this.storage.getList().then(favList => {
       favList.forEach(element => {
         file += `${JSON.stringify(element)}\n`;
       });
      this.export(file, 'json', readySource);
     })
   })
 }
開發者ID:PierrePlessy,項目名稱:pple_ultimateMovie,代碼行數:11,代碼來源:download.service.ts

示例6: of

 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

示例7: downloadPoster

 downloadPoster(poster: string, nameDownload: string) {
   if(!poster) return
   this.platform.ready().then(readySource => {
     if (readySource == "android" || readySource == "cordova") {
       const fileRoot = new File();
       this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE).then(res => {
         if (res.hasPermission) {
           const upload = this.fileTransfer.create();
           console.log(poster)
           upload.download(poster, `${fileRoot.externalRootDirectory}/Download/blob.jpg`)
           .then(foo => console.log("ok download poster", foo))
         }
       })
     }
   })
 }
開發者ID:PierrePlessy,項目名稱:pple_ultimateMovie,代碼行數:16,代碼來源:download.service.ts

示例8: 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

示例9: if

 uploadFavorites() {
   console.log("Upload");
   this.platform.ready().then(readySource => {
     if (readySource == "android" || readySource == "cordova") {
       this.fileChooser.open()
         .then(uri => {
           this.filePath.resolveNativePath(uri)
             .then(url => {
               const path = url.split('/');
               const filename = path.pop();
               const directory = `${path.join("/")}/`
               this.file.readAsText(directory, filename)
                 .then(res => {
                   if (url.endsWith(".json")) {
                     const newFav = new Array<Object>();
                     res.split("\n").forEach(element => {
                       if (element) newFav.push(JSON.parse(element))
                     })
                     this.storage.importFavorites(newFav);
                   }
                   else if (url.endsWith(".csv")) {
                     csv2json().fromString(res).then(resJSON => {
                       this.storage.importFavorites(resJSON);
                     })
                   }
                 })
                 .catch(err => {
                   console.log("Error read file export", err);
                 })
             })
         })
         .catch(err => {
           console.log("Error chooser", err)
         })
     }
   })
 }
開發者ID:PierrePlessy,項目名稱:pple_ultimateMovie,代碼行數:37,代碼來源:upload.service.ts

示例10: initializeApp

 initializeApp() {
   this.platform.ready().then(() => {
     this.statusBar.styleDefault();
     this.splashScreen.hide();
   });
 }
開發者ID:dpa99c,項目名稱:phonegap-launch-navigator-example,代碼行數:6,代碼來源:app.component.ts


注:本文中的@ionic/angular.Platform類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。