2017-08-12 46 views
0

我試圖在TouchableOpacity媒體上推出YouTube應用程序,但每次我都會在Safari瀏覽器中啓動YouTube。React-Native - 在按鈕上啓動YouTube應用程序

我的實現可以見下圖:

openURL(url) { 
    Linking.canOpenURL(url).then(supported => { 
    if (!supported) { 
     console.log('Can\'t handle url: ' + url); 
    } else { 
     return Linking.openURL(url); 
    } 
    }).catch(err => console.error('An error occurred', err)); 
} 

<TouchableOpacity 
    style={styles.youtubeButton} 
    onPress={ 
    () => this.openURL('https://www.youtube.com/channel/UCnJ...') 
    }> 
    <Text style={styles.youtubeButtonText}>Subscribe on YouTube</Text> 
</TouchableOpacity> 

我一直在使用youtube://www.youtube.com/channel/channelname的URL嘗試,但按鈕不採取任何措施。

非常感謝您的任何建議!

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/channel/UC22CRSLaKXvUQaod8unRFZQ"))); 
Log.i("Video", "Video Playing...."); 

我通過編輯這個問題的答案得到了這樣的回答:這對我來說代碼打開一個Chanel在YouTube應用

回答

相關問題