Skip to content

Commit b26f277

Browse files
utkarsh-dixitfacebook-github-bot
authored andcommitted
Add Linking examples in rn-tester (#30547)
Summary: Added examples to RNTester for the Linking API. ## Changelog [General] [Added] - Added example for openSettings() for Linking API. [General] [Added] - Added [LSApplicationQueriesSchemes](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW14) in info.plist with entries tel, telprompt, http, fb, geo Pull Request resolved: #30547 Test Plan: ![Screen Recording 2020-12-07 at 11 19 13 PM (1)](https://user-images.githubusercontent.com/16796008/102250807-05001580-3f2a-11eb-9ce0-58de4d6fca54.gif) Reviewed By: yungsters Differential Revision: D30559457 Pulled By: lunaleaps fbshipit-source-id: dba2721a9905ddb9ddd2b14141e5553bdf8880da
1 parent ac4ddec commit b26f277

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

packages/rn-tester/RNTester/Info.plist

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>LSApplicationQueriesSchemes</key>
6+
<array>
7+
<string>tel</string>
8+
<string>telprompt</string>
9+
<string>http</string>
10+
<string>fb</string>
11+
<string>geo</string>
12+
</array>
513
<key>UIStatusBarStyle</key>
614
<string>UIStatusBarStyleBlackTranslucent</string>
715
<key>CFBundleDevelopmentRegion</key>

packages/rn-tester/js/examples/Linking/LinkingExample.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
const React = require('react');
1313
const {
14+
Button,
1415
Linking,
1516
Platform,
1617
StyleSheet,
@@ -48,6 +49,16 @@ class OpenURLButton extends React.Component<Props> {
4849
}
4950
}
5051

52+
class OpenSettingsExample extends React.Component<Props, any> {
53+
openSettings() {
54+
Linking.openSettings();
55+
}
56+
57+
render() {
58+
return <Button onPress={this.openSettings} title={'Open Settings'} />;
59+
}
60+
}
61+
5162
class SendIntentButton extends React.Component<Props> {
5263
handleIntent = async () => {
5364
try {
@@ -72,14 +83,14 @@ class IntentAndroidExample extends React.Component {
7283
render() {
7384
return (
7485
<View>
75-
<RNTesterBlock title="Open external URLs">
86+
<View>
7687
<OpenURLButton url={'https://www.facebook.com'} />
7788
<OpenURLButton url={'http://www.facebook.com'} />
7889
<OpenURLButton url={'http://facebook.com'} />
7990
<OpenURLButton url={'fb://notifications'} />
8091
<OpenURLButton url={'geo:37.484847,-122.148386'} />
8192
<OpenURLButton url={'tel:9876543210'} />
82-
</RNTesterBlock>
93+
</View>
8394
{Platform.OS === 'android' && (
8495
<RNTesterBlock title="Send intents">
8596
<SendIntentButton action="android.intent.action.POWER_USAGE_SUMMARY" />
@@ -122,9 +133,15 @@ exports.documentationURL = 'https://reactnative.dev/docs/linking';
122133
exports.description = 'Shows how to use Linking to open URLs.';
123134
exports.examples = [
124135
{
125-
title: 'Simple list of items',
136+
title: 'Open external URLs',
126137
render: function(): React.Element<typeof IntentAndroidExample> {
127138
return <IntentAndroidExample />;
128139
},
129140
},
141+
{
142+
title: 'Open settings app',
143+
render: function(): React.Element<typeof LinkingChangesListenerExample> {
144+
return <OpenSettingsExample />;
145+
},
146+
},
130147
];

0 commit comments

Comments
 (0)