首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Ionic 4中启动外部应用程序的白屏

在Ionic 4中启动外部应用程序的白屏
EN

Stack Overflow用户
提问于 2019-07-01 21:42:18
回答 1查看 391关注 0票数 1

我有一个页面,它想要启动外部应用程序时,一个按钮被点击,函数goToApp()应该运行。

以下是我在ts文件上的代码,但页面上的所有内容都可以加载到我添加的位置

从‘@ionic-native/app-launcher/ngx’导入{ AppLauncher,AppLauncherOptions };

然后页面就不会再加载了。未返回错误代码。有什么想法吗?提前谢谢。

代码语言:javascript
复制
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'));
        }


}

EN

回答 1

Stack Overflow用户

发布于 2019-07-02 11:45:38

您是否遵循了向应用程序添加新模块时需要执行的标准部分:

基本上,您需要将模块注入到应用程序中:

代码语言:javascript
复制
// app.module.ts
import { AppLauncher } from '@ionic-native/app-launcher/ngx';

...

@NgModule({
  ...

  providers: [
    ...
    AppLauncher
    ...
  ]
  ...
})
export class AppModule { }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56836764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档