【问题标题】:Ionic app deep links are not working properlyIonic 应用深层链接无法正常工作
【发布时间】:2021-10-09 15:21:42
【问题描述】:

在此代码中,当我单击按钮时,它总是打开 https://apps.apple.com URL 而不是打开 App Store。我想实现,如果应用程序未安装在设备中,那么它应该只去 App Store,否则它应该打开这个 URL:https://apps.apple.com

popover.onDidDismiss()
    .then(async (decision) => {
        if (exiStatus.status === 'registered' && decision.data) {
            const options: AppLauncherOptions = {}
            if (this.platform.is('ios')) {
                options.uri = 'exiapp://referral'
            } else {
                options.packageName = 'com.iprescribeexercise.app.android.iPrescribe'
            }
            this.appLauncher.canLaunch(options)
                .then((canLaunch: boolean) => {
                    this.appLauncher.launch(options);
                })
                .catch((error: any) => {
                    if (this.platform.is('ios')) {
                        window.open('https://apps.apple.com')
                    } else {
                        window.open('https://play.google.com/store/apps/details?id=com.iprescribeexercise.app.android.iPrescribe')
                    }
                });

【问题讨论】:

    标签: angular ionic-framework deep-linking


    【解决方案1】:
    App.addListener('appUrlOpen', (data: any) => {
           console.log(data,"chintan");
          this.zone.run(() => {
            // Example url: https://beerswift.app/tabs/tab2
            // slug = /tabs/tab2
            const slug = data.url.split("apps.").pop();
            
            if (slug == "apple.com") {
             // DO SOMTHING
            }
            else {
             
              this.router.navigateByUrl("/");
            }
            // If no match, do nothing - let regular routing
            // logic take over
          });
        });
    

    initializeApp() 方法中将此代码添加到 appcomponent.ts 中,如果您正在运行,请在 ma​​nifaist 文件 中添加一些行安卓。

    https://capacitorjs.com/docs/guides/deep-links点击此链接,您将获得所有答案。

    【讨论】:

      猜你喜欢
      • 2018-11-17
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 2019-02-26
      • 1970-01-01
      • 2012-12-27
      • 1970-01-01
      相关资源
      最近更新 更多