LoginSignup
1
0

More than 1 year has passed since last update.

Androidアプリでリンクを開けるようにする

Last updated at Posted at 2022-03-24

#はじめに
Cordovaプラグインを使用して、Androidアプリでリンクを開けるようにする。
使用したのはcordova-webintent

iOSではInAppBrowserを使用する必要がある。

#コード
src-cordovaディレクトリにインストール。

cd src-cordova
cordova plugin add github:cordova-misc/cordova-webintent.git

関数を作成。

openLink() {
  window.plugins.webintent.startActivity(
    {
      action : window.plugins.webintent.ACTION_VIEW
      ,url   : 'https://~~~'
    }
    ,function(){}
    ,function(){ alert ('Failed to open URL via Android Intent'); }
  )
}

TypeScriptでエラーが出る場合は、declareを使う。

declare let window: any;

#参考サイト

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0