![](/img/trans.png)
[英]Ionic app freezes and display a blank white screen when I launch it in airplane mode. what is happening?
[英]White Screen for Launch External App in Ionic 4
我有一個頁面想要在單擊按鈕時啟動外部應用程序並且函數 goToApp() 應該運行。
以下是我在 ts 文件上的代碼,但頁面上的所有內容都可以加載,直到我添加點
從“@ionic-native/app-launcher/ngx”導入 { AppLauncher, AppLauncherOptions };
在它之后頁面不再加載。 沒有返回錯誤代碼。 任何的想法? 提前致謝。
import { Component,OnInit,Input } from '@angular/core'; import { AppLauncher, AppLauncherOptions } from '@ionic-native/app-launcher/ngx'; import { ModalController, Platform } from '@ionic/angular'; import { DomSanitizer,SafeResourceUrl } from '@angular/platform-browser'; /* Generated class for the Posts page. See http://ionicframework.com/docs/v2/components/#navigation for more info on Ionic pages and navigation. */ @Component({ selector: 'page-fsfastcheck', templateUrl: 'fsfastcheck.html', styleUrls: ['fsfastcheck.scss'], }) export class FSFastCheckPage implements OnInit { @Input() url: string = "https://eastchenconsultancy.com/feng-shui-fast-check/"; url2: string = "https://eastchenconsultancy.com/appointment-list/"; urlSafe: SafeResourceUrl; urlSafe2: SafeResourceUrl; mySegment: string = 'travelrequest'; constructor( public modalView: ModalController, public sanitizer: DomSanitizer, private appLauncher: AppLauncher, private platform: Platform) { } ngOnInit() { this.urlSafe= this.sanitizer.bypassSecurityTrustResourceUrl(this.url); this.urlSafe2= this.sanitizer.bypassSecurityTrustResourceUrl(this.url2); } close() { this.modalView.dismiss(); } goToApp() { const options: AppLauncherOptions = { } if(this.platform.is('ios')) { options.packageName = 'com.apple.compass' } else { options.packageName = 'com.gn.android.compass' } this.appLauncher.canLaunch(options) .then((canLaunch: boolean) => console.log('Compass is available')) .catch((error: any) => console.error('Compass is not available')); } }
您是否遵循了向應用程序添加新模塊時需要執行的標准部分:
基本上,您需要將模塊注入應用程序:
// app.module.ts
import { AppLauncher } from '@ionic-native/app-launcher/ngx';
...
@NgModule({
...
providers: [
...
AppLauncher
...
]
...
})
export class AppModule { }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.