Summary:Since `IntentAndroid` is being deprecated and `Linking` is the new API to deal with URLs, here comes the basic `Linking` API example. :)
Closes https://github.com/facebook/react-native/pull/6194

Differential Revision: D2988614

Pulled By: javache

fb-gh-sync-id: a98daa8e57ec6f59ecf3182fa4b21e81ad55f1c0
shipit-source-id: a98daa8e57ec6f59ecf3182fa4b21e81ad55f1c0
This commit is contained in:
Satyajit Sahoo 2016-02-29 03:28:48 -08:00 коммит произвёл Facebook Github Bot 3
Родитель 44fcf22074
Коммит 79e9489580
3 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -15,7 +15,7 @@
var React = require('react-native');
var {
IntentAndroid,
Linking,
StyleSheet,
Text,
TouchableNativeFeedback,
@ -30,9 +30,9 @@ var OpenURLButton = React.createClass({
},
handleClick: function() {
IntentAndroid.canOpenURL(this.props.url, (supported) => {
Linking.canOpenURL(this.props.url).then(supported => {
if (supported) {
IntentAndroid.openURL(this.props.url);
Linking.openURL(this.props.url);
} else {
console.log('Don\'t know how to open URI: ' + this.props.url);
}
@ -54,8 +54,8 @@ var OpenURLButton = React.createClass({
var IntentAndroidExample = React.createClass({
statics: {
title: 'IntentAndroid',
description: 'Shows how to use Android Intents to open URLs.',
title: 'Linking',
description: 'Shows how to use Linking to open URLs.',
},
render: function() {
@ -64,7 +64,9 @@ var IntentAndroidExample = React.createClass({
<OpenURLButton url={'https://www.facebook.com'} />
<OpenURLButton url={'http://www.facebook.com'} />
<OpenURLButton url={'http://facebook.com'} />
<OpenURLButton url={'fb://notifications'} />
<OpenURLButton url={'geo:37.484847,-122.148386'} />
<OpenURLButton url={'tel:9876543210'} />
</UIExplorerBlock>
);
},

Просмотреть файл

@ -120,14 +120,14 @@ const APIExamples = [
key: 'ImageEditingExample',
module: require('./ImageEditingExample'),
},
{
key: 'IntentAndroidExample',
module: require('./IntentAndroidExample'),
},
{
key: 'LayoutEventsExample',
module: require('./LayoutEventsExample'),
},
{
key: 'LinkingExample',
module: require('./LinkingExample'),
},
{
key: 'LayoutExample',
module: require('./LayoutExample'),

Просмотреть файл

@ -196,6 +196,10 @@ var APIExamples: Array<UIExplorerExample> = [
key: 'LayoutExample',
module: require('./LayoutExample'),
},
{
key: 'LinkingExample',
module: require('./LinkingExample'),
},
{
key: 'NavigationExperimentalExample',
module: require('./NavigationExperimental/NavigationExperimentalExample'),