11
11
12
12
const React = require ( 'react' ) ;
13
13
const {
14
+ Button,
14
15
Linking,
15
16
Platform,
16
17
StyleSheet,
@@ -48,6 +49,16 @@ class OpenURLButton extends React.Component<Props> {
48
49
}
49
50
}
50
51
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
+
51
62
class SendIntentButton extends React . Component < Props > {
52
63
handleIntent = async ( ) => {
53
64
try {
@@ -72,14 +83,14 @@ class IntentAndroidExample extends React.Component {
72
83
render ( ) {
73
84
return (
74
85
< View >
75
- < RNTesterBlock title = "Open external URLs" >
86
+ < View >
76
87
< OpenURLButton url = { 'https://www.facebook.com' } />
77
88
< OpenURLButton url = { 'http://www.facebook.com' } />
78
89
< OpenURLButton url = { 'http://facebook.com' } />
79
90
< OpenURLButton url = { 'fb://notifications' } />
80
91
< OpenURLButton url = { 'geo:37.484847,-122.148386' } />
81
92
< OpenURLButton url = { 'tel:9876543210' } />
82
- </ RNTesterBlock >
93
+ </ View >
83
94
{ Platform . OS === 'android' && (
84
95
< RNTesterBlock title = "Send intents" >
85
96
< SendIntentButton action = "android.intent.action.POWER_USAGE_SUMMARY" />
@@ -122,9 +133,15 @@ exports.documentationURL = 'https://reactnative.dev/docs/linking';
122
133
exports . description = 'Shows how to use Linking to open URLs.' ;
123
134
exports . examples = [
124
135
{
125
- title : 'Simple list of items ' ,
136
+ title : 'Open external URLs ' ,
126
137
render : function ( ) : React . Element < typeof IntentAndroidExample > {
127
138
return < IntentAndroidExample / > ;
128
139
} ,
129
140
} ,
141
+ {
142
+ title : 'Open settings app' ,
143
+ render : function ( ) : React . Element < typeof LinkingChangesListenerExample > {
144
+ return < OpenSettingsExample / > ;
145
+ } ,
146
+ } ,
130
147
] ;
0 commit comments