2016-02-24 11 views

答えて

12

あなたはInfo.plistにアレイのparamとしてLSApplicationQueriesSchemesを追加し、それにアイテムを追加する必要があります。

例えばAppStoreのリンクでは、私はitms-appsをこの配列のparamsの1つとして使用します。

あなたのリンクは、この

itms-apps://itunes.apple.com/us/app/id${APP_STORE_LINK_ID}?mt=8ようにする必要があります。

今あなたはすべてのものを持っているメソッドとのリンクコンポーネント

handleClick() { 
    Linking.canOpenURL(link).then(supported => { 
     supported && Linking.openURL(link); 
    }, (err) => console.log(err)); 
} 
+0

を参照してください。 'LSApplicationQueriesSchemes'は、iOS 9+用にビルドする場合にのみ必要です。http://facebook.github.io/react-native/docs/linking.html#canopenurl –

+0

iOSシミュレータにはPlayストアがインストールされていないため、これはsimulaで常に失敗しますトルーマン実際のデバイスでテストする必要があります。 –

5

Linkingを使用して、アプリケーションストアへのURLを開きます。適切なURLを作成するには、iOSおよび/またはandroidの手順に従ってください。例えば。

Linking.openURL('market://details?id=myandroidappid') 

または

Linking.openURL('itms://itunes.apple.com/us/app/apple-store/myiosappid?mt=8') 
+1

なぜdownvoteですか?これは機能しませんか? –

+0

これはうまくいくはずですが、iOS 9以降のビルドには、ここで説明するように 'LSApplicationQueriesSchemes'を追加する必要があります。http://facebook.github.io/react-native/docs/linking.html#canopenurl –

+1

iOSシミュレータ( –

3

これは何か似ている、それはアプリを更新する警告ボックスを表示し、それは彼らのデバイスのOSに応じて、Playストアやアプリストアを開きます。 iOS用

function updateAppNotice(){ 
    const APP_STORE_LINK = 'itms://itunes.apple.com/us/app/apple-store/myiosappid?mt=8'; 
    const PLAY_STORE_LINK = 'market://details?id=myandroidappid'; 
    Alert.alert(
     'Update Available', 
     'This version of the app is outdated. Please update app from the '+(Platform.OS =='ios' ? 'app store' : 'play store')+'.', 
     [ 
      {text: 'Update Now', onPress:() => { 
       if(Platform.OS =='ios'){ 
        Linking.openURL(APP_STORE_LINK).catch(err => console.error('An error occurred', err)); 
       } 
       else{ 
        Linking.openURL(PLAY_STORE_LINK).catch(err => console.error('An error occurred', err)); 
       } 
      }}, 
     ] 
    ); 
} 
+0

'mt = 8'とは何ですか?これは地域固有で必要なのかどうか疑問に思っていますか? –

+1

@AnshulKoka、mtは"メディアタイプ "、値8は"モバイルソフトウェアアプリケーション "に対応しています。詳細はhttps://stackoverflow.com/questions/1781427/what-is-mt-8-in-itunes-link-for-the-appstore – mihai1990

関連する問題