Add 'Linking' example
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:
Родитель
44fcf22074
Коммит
79e9489580
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
var React = require('react-native');
|
var React = require('react-native');
|
||||||
var {
|
var {
|
||||||
IntentAndroid,
|
Linking,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
TouchableNativeFeedback,
|
TouchableNativeFeedback,
|
||||||
|
@ -30,9 +30,9 @@ var OpenURLButton = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
handleClick: function() {
|
handleClick: function() {
|
||||||
IntentAndroid.canOpenURL(this.props.url, (supported) => {
|
Linking.canOpenURL(this.props.url).then(supported => {
|
||||||
if (supported) {
|
if (supported) {
|
||||||
IntentAndroid.openURL(this.props.url);
|
Linking.openURL(this.props.url);
|
||||||
} else {
|
} else {
|
||||||
console.log('Don\'t know how to open URI: ' + this.props.url);
|
console.log('Don\'t know how to open URI: ' + this.props.url);
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ var OpenURLButton = React.createClass({
|
||||||
var IntentAndroidExample = React.createClass({
|
var IntentAndroidExample = React.createClass({
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
title: 'IntentAndroid',
|
title: 'Linking',
|
||||||
description: 'Shows how to use Android Intents to open URLs.',
|
description: 'Shows how to use Linking to open URLs.',
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
@ -64,7 +64,9 @@ var IntentAndroidExample = React.createClass({
|
||||||
<OpenURLButton url={'https://www.facebook.com'} />
|
<OpenURLButton url={'https://www.facebook.com'} />
|
||||||
<OpenURLButton url={'http://www.facebook.com'} />
|
<OpenURLButton url={'http://www.facebook.com'} />
|
||||||
<OpenURLButton url={'http://facebook.com'} />
|
<OpenURLButton url={'http://facebook.com'} />
|
||||||
|
<OpenURLButton url={'fb://notifications'} />
|
||||||
<OpenURLButton url={'geo:37.484847,-122.148386'} />
|
<OpenURLButton url={'geo:37.484847,-122.148386'} />
|
||||||
|
<OpenURLButton url={'tel:9876543210'} />
|
||||||
</UIExplorerBlock>
|
</UIExplorerBlock>
|
||||||
);
|
);
|
||||||
},
|
},
|
|
@ -120,14 +120,14 @@ const APIExamples = [
|
||||||
key: 'ImageEditingExample',
|
key: 'ImageEditingExample',
|
||||||
module: require('./ImageEditingExample'),
|
module: require('./ImageEditingExample'),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'IntentAndroidExample',
|
|
||||||
module: require('./IntentAndroidExample'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'LayoutEventsExample',
|
key: 'LayoutEventsExample',
|
||||||
module: require('./LayoutEventsExample'),
|
module: require('./LayoutEventsExample'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'LinkingExample',
|
||||||
|
module: require('./LinkingExample'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'LayoutExample',
|
key: 'LayoutExample',
|
||||||
module: require('./LayoutExample'),
|
module: require('./LayoutExample'),
|
||||||
|
|
|
@ -196,6 +196,10 @@ var APIExamples: Array<UIExplorerExample> = [
|
||||||
key: 'LayoutExample',
|
key: 'LayoutExample',
|
||||||
module: require('./LayoutExample'),
|
module: require('./LayoutExample'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'LinkingExample',
|
||||||
|
module: require('./LinkingExample'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'NavigationExperimentalExample',
|
key: 'NavigationExperimentalExample',
|
||||||
module: require('./NavigationExperimental/NavigationExperimentalExample'),
|
module: require('./NavigationExperimental/NavigationExperimentalExample'),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче