26
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

React Nativeで外部リンクをブラウザで開く

Last updated at Posted at 2017-02-03

概要

アプリから特定のURLをブラウザで開く方法についてのメモです。

実装

Linking APIを使用します。

Linking.openURL(url).catch(err => console.error('URLを開けませんでした。', err));

URLを開く前にURLが有効かを判別したい場合以下のように書きます。

Linking.canOpenURL(url).then(supported => {
  if (!supported) {
    console.log('無効なURLです: ' + url);
  } else {
    return Linking.openURL(url);
  }
}).catch(err => console.error('URLを開けませんでした。', err));

参考

26
16
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
26
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?