簡體   English   中英

如何使用來自 Ionic App 的自定義 URL 方案啟動外部打開的應用程序?

[英]How to launch external opened app using custom URL scheme from Ionic App?

我想使用自定義 URL 方案從 ionic 應用程序 A 從外部啟動打開的應用程序 B。

嘗試過的解決方案

  1. Plugin In App Browser ,能夠在離子應用程序本身中啟動外部應用程序,而不是啟動打開的外部應用程序。
const target = '_system';
    let url = 'abc123://abc.com/mobile/details/' + Id;

    const options: InAppBrowserOptions = {
      zoom: 'no',
      location: 'no',
      hidden: 'yes'
    };

    this.loadingProvider.dismiss();
    this.inAppBrowserRef = this.inAppBrowser.create(url, target, options);
  1. 插件應用程序啟動器 對於 android,它能夠啟動外部應用程序,但使用 package 名稱而不是自定義 URL 方案

我在模板中使用錨標記,並設置target="_blank" 這是來自 Ionic 5 應用程序,但我只在完整的 iOS 版本中進行了測試,我還沒有 Android 版本。 我也在使用電容器,但我認為這不會改變瀏覽器的行為。

<a [href]="website" target="_blank">{{ website }}</a>

target="_blank"導致它在主操作系統瀏覽器中打開 URL。 然后主瀏覽器應該處理您的自定義鏈接。

如果您有自定義 URL 可以打開使用

window.open('Your URL','_system');

在你的代碼中。 這可以在 Android 和 ios 平台上完美運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM