Skip to content

Commit 63e54d5

Browse files
committed
Simplify getting started
1 parent 4a0997d commit 63e54d5

File tree

6 files changed

+149
-98
lines changed

6 files changed

+149
-98
lines changed

docs/deep-linking.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ First, you will want to specify a url scheme for your app. This corresponds to t
7070
}
7171
```
7272

73-
7473
### URI Prefix
7574

76-
Next, let's configure our navigation container to extract the path from the app's incoming URI.
75+
Next, let's configure our navigation container to extract the path from the app's incoming URI.
7776

7877
```js
7978
import * as Expo from 'expo';
@@ -91,10 +90,10 @@ The reason that is necessary to use `Expo.Linking.makeUrl` is that the scheme wi
9190

9291
To test the URI on the simulator in the Expo client app, run the following:
9392

94-
```
93+
```sh
9594
xcrun simctl openurl booted [ put your URI prefix in here ]
9695

97-
// for example
96+
# for example
9897

9998
xcrun simctl openurl booted exp://127.0.0.1:19000/--/chat/Eric
10099
```
@@ -103,10 +102,10 @@ xcrun simctl openurl booted exp://127.0.0.1:19000/--/chat/Eric
103102

104103
To test the intent handling in Android (Expo client app ), run the following:
105104

106-
```
105+
```sh
107106
adb shell am start -W -a android.intent.action.VIEW -d "[ put your URI prefix in here ]" com.simpleapp
108107

109-
// for example
108+
# for example
110109

111110
adb shell am start -W -a android.intent.action.VIEW -d "exp://127.0.0.1:19000/--/chat/Eric" com.simpleapp
112111
```
@@ -117,7 +116,7 @@ Read the [Expo linking guide](https://docs.expo.io/versions/latest/guides/linkin
117116

118117
### URI Prefix
119118

120-
Next, let's configure our navigation container to extract the path from the app's incoming URI.
119+
Next, let's configure our navigation container to extract the path from the app's incoming URI.
121120

122121
```js
123122
const SimpleApp = createAppContainer(createStackNavigator({...}));
@@ -133,7 +132,7 @@ Let's configure the native iOS app to open based on the `mychat://` URI scheme.
133132

134133
In `SimpleApp/ios/SimpleApp/AppDelegate.m`:
135134

136-
```
135+
```objc
137136
// Add the header at the top of the file:
138137
#import <React/RCTLinkingManager.h>
139138

@@ -158,7 +157,7 @@ react-native run-ios
158157

159158
To test the URI on the simulator, run the following:
160159

161-
```
160+
```sh
162161
xcrun simctl openurl booted mychat://chat/Eric
163162
```
164163

@@ -172,7 +171,7 @@ In `SimpleApp/android/app/src/main/AndroidManifest.xml`, do these followings adj
172171
1. Set `launchMode` of `MainActivity` to `singleTask` in order to receive intent on existing `MainActivity`. It is useful if you want to perform navigation using deep link you have been registered - [details](http://developer.android.com/training/app-indexing/deep-linking.html#adding-filters)
173172
2. Add the new `intent-filter` inside the `MainActivity` entry with a `VIEW` type action:
174173

175-
```
174+
```xml
176175
<activity
177176
android:name=".MainActivity"
178177
android:launchMode="singleTask">
@@ -184,7 +183,7 @@ In `SimpleApp/android/app/src/main/AndroidManifest.xml`, do these followings adj
184183
<action android:name="android.intent.action.VIEW" />
185184
<category android:name="android.intent.category.DEFAULT" />
186185
<category android:name="android.intent.category.BROWSABLE" />
187-
<data android:scheme="mychat" />
186+
<data android:scheme="mychat" />
188187
</intent-filter>
189188
</activity>
190189
```
@@ -197,10 +196,22 @@ react-native run-android
197196

198197
To test the intent handling in Android, run the following:
199198

200-
```
199+
```sh
201200
adb shell am start -W -a android.intent.action.VIEW -d "mychat://chat/Eric" com.simpleapp
202201
```
203202

203+
## Hybrid iOS Applications (Skip for RN only projects)
204+
205+
If you're using React Navigation within a hybrid app - an iOS app that has both Swift/ObjC and React Native parts - you may be missing the `RCTLinkingIOS` subspec in your Podfile, which is installed by default in new RN projects. To add this, ensure your Podfile looks like the following:
206+
207+
```pod
208+
pod 'React', :path => '../node_modules/react-native', :subspecs => [
209+
. . . // other subspecs
210+
'RCTLinkingIOS',
211+
. . .
212+
]
213+
```
214+
204215
## Disable deep linking
205216

206217
In case you want to handle routing with deep-linking by yourself instead of `react-navigation`, you can pass `enableURLHandling={false}` prop to your app container:

website/versioned_docs/version-4.x/drawer-navigator.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,38 @@ Next, we need to link these libraries. The steps depends on your React Native ve
5050
react-native link react-native-gesture-handler
5151
```
5252

53-
**IMPORTANT:** There are additional steps required for `react-native-gesture-handler` on Android after linking (for all React Native versions). Check the [this guide](https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html) to complete the installation.
53+
To finalize installation of `react-native-gesture-handler` for Android, be sure to make the necessary modifications to `MainActivity.java`:
54+
55+
```diff
56+
package com.reactnavigation.example;
57+
58+
import com.facebook.react.ReactActivity;
59+
+ import com.facebook.react.ReactActivityDelegate;
60+
+ import com.facebook.react.ReactRootView;
61+
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
62+
63+
public class MainActivity extends ReactActivity {
64+
65+
@Override
66+
protected String getMainComponentName() {
67+
return "Example";
68+
}
69+
70+
+ @Override
71+
+ protected ReactActivityDelegate createReactActivityDelegate() {
72+
+ return new ReactActivityDelegate(this, getMainComponentName()) {
73+
+ @Override
74+
+ protected ReactRootView createRootView() {
75+
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
76+
+ }
77+
+ };
78+
+ }
79+
}
80+
```
81+
82+
Finally, run `react-native run-android` or `react-native run-ios` to launch the app on your device/simulator.
83+
84+
## API Definition
5485

5586
Then import it from `react-navigation-drawer`:
5687

website/versioned_docs/version-4.x/getting-started.md

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -25,86 +25,6 @@ yarn add react-navigation
2525
# npm install react-navigation
2626
```
2727

28-
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler) and [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated).
28+
When you use a navigator, you'll need to follow the installation instructions of that navigator for any additional configuration.
2929

30-
If you are using Expo, to ensure that you get the compatible versions of the libraries, run:
31-
32-
```sh
33-
expo install react-native-gesture-handler react-native-reanimated
34-
```
35-
36-
If you are not using Expo, run the following:
37-
38-
```sh
39-
yarn add react-native-reanimated react-native-gesture-handler
40-
```
41-
42-
If you are using Expo, you are done. Otherwise, continue to the next steps.
43-
44-
Next, we need to link these libraries. The steps depends on your React Native version:
45-
46-
- **React Native 0.60 and higher**
47-
48-
On newer versions of React Native, [linking is automatic](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md).
49-
50-
To complete the linking on iOS, make sure you have [Cocoapods](https://cocoapods.org/) installed. Then run:
51-
52-
```sh
53-
cd ios
54-
pod install
55-
cd ..
56-
```
57-
58-
- **React Native 0.59 and lower**
59-
60-
If you're on an older React Native version, you need to manually link the dependencies. To do that, run:
61-
62-
```sh
63-
react-native link react-native-reanimated
64-
react-native link react-native-gesture-handler
65-
```
66-
67-
To finalize installation of `react-native-gesture-handler` for Android, be sure to make the necessary modifications to `MainActivity.java`:
68-
69-
```diff
70-
package com.reactnavigation.example;
71-
72-
import com.facebook.react.ReactActivity;
73-
+ import com.facebook.react.ReactActivityDelegate;
74-
+ import com.facebook.react.ReactRootView;
75-
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
76-
77-
public class MainActivity extends ReactActivity {
78-
79-
@Override
80-
protected String getMainComponentName() {
81-
return "Example";
82-
}
83-
84-
+ @Override
85-
+ protected ReactActivityDelegate createReactActivityDelegate() {
86-
+ return new ReactActivityDelegate(this, getMainComponentName()) {
87-
+ @Override
88-
+ protected ReactRootView createRootView() {
89-
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
90-
+ }
91-
+ };
92-
+ }
93-
}
94-
```
95-
96-
Finally, run `react-native run-android` or `react-native run-ios` to launch the app on your device/simulator.
97-
98-
## Hybrid iOS Applications (Skip for RN only projects)
99-
100-
If you're using React Navigation within a hybrid app - an iOS app that has both Swift/ObjC and React Native parts - you may be missing the `RCTLinkingIOS` subspec in your Podfile, which is installed by default in new RN projects. To add this, ensure your Podfile looks like the following:
101-
102-
```
103-
pod 'React', :path => '../node_modules/react-native', :subspecs => [
104-
. . . // other subspecs
105-
'RCTLinkingIOS',
106-
. . .
107-
]
108-
```
109-
110-
You're good to go! Continue to ["Hello React Navigation"](hello-react-navigation.html) to start writing some code.
30+
Continue to ["Hello React Navigation"](hello-react-navigation.html) to start writing some code.

website/versioned_docs/version-4.x/material-top-tab-navigator.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,38 @@ Next, we need to link these libraries. The steps depends on your React Native ve
5252
react-native link react-native-gesture-handler
5353
```
5454

55-
**IMPORTANT:** There are additional steps required for `react-native-gesture-handler` on Android after linking (for all React Native versions). Check the [this guide](https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html) to complete the installation.
55+
To finalize installation of `react-native-gesture-handler` for Android, be sure to make the necessary modifications to `MainActivity.java`:
56+
57+
```diff
58+
package com.reactnavigation.example;
59+
60+
import com.facebook.react.ReactActivity;
61+
+ import com.facebook.react.ReactActivityDelegate;
62+
+ import com.facebook.react.ReactRootView;
63+
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
64+
65+
public class MainActivity extends ReactActivity {
66+
67+
@Override
68+
protected String getMainComponentName() {
69+
return "Example";
70+
}
71+
72+
+ @Override
73+
+ protected ReactActivityDelegate createReactActivityDelegate() {
74+
+ return new ReactActivityDelegate(this, getMainComponentName()) {
75+
+ @Override
76+
+ protected ReactRootView createRootView() {
77+
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
78+
+ }
79+
+ };
80+
+ }
81+
}
82+
```
83+
84+
Finally, run `react-native run-android` or `react-native run-ios` to launch the app on your device/simulator.
85+
86+
## API Definition
5687

5788
To use this tab navigator, import it from `react-navigation-tabs`:
5889

website/versioned_docs/version-4.x/stack-navigator-2.0.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,36 @@ Next, we need to link these libraries. The steps depends on your React Native ve
5656
react-native link react-native-gesture-handler
5757
```
5858

59-
**IMPORTANT:** There are additional steps required for `react-native-gesture-handler` on Android after linking (for all React Native versions). Check the [this guide](https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html) to complete the installation.
59+
To finalize installation of `react-native-gesture-handler` for Android, be sure to make the necessary modifications to `MainActivity.java`:
60+
61+
```diff
62+
package com.reactnavigation.example;
63+
64+
import com.facebook.react.ReactActivity;
65+
+ import com.facebook.react.ReactActivityDelegate;
66+
+ import com.facebook.react.ReactRootView;
67+
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
68+
69+
public class MainActivity extends ReactActivity {
70+
71+
@Override
72+
protected String getMainComponentName() {
73+
return "Example";
74+
}
75+
76+
+ @Override
77+
+ protected ReactActivityDelegate createReactActivityDelegate() {
78+
+ return new ReactActivityDelegate(this, getMainComponentName()) {
79+
+ @Override
80+
+ protected ReactRootView createRootView() {
81+
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
82+
+ }
83+
+ };
84+
+ }
85+
}
86+
```
87+
88+
Finally, run `react-native run-android` or `react-native run-ios` to launch the app on your device/simulator.
6089

6190
## API Definition
6291

website/versioned_docs/version-4.x/stack-navigator.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,36 @@ Next, we need to link these libraries. The steps depends on your React Native ve
5353
react-native link react-native-gesture-handler
5454
```
5555

56-
**IMPORTANT:** There are additional steps required for `react-native-gesture-handler` on Android after linking (for all React Native versions). Check the [this guide](https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html) to complete the installation.
56+
To finalize installation of `react-native-gesture-handler` for Android, be sure to make the necessary modifications to `MainActivity.java`:
57+
58+
```diff
59+
package com.reactnavigation.example;
60+
61+
import com.facebook.react.ReactActivity;
62+
+ import com.facebook.react.ReactActivityDelegate;
63+
+ import com.facebook.react.ReactRootView;
64+
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
65+
66+
public class MainActivity extends ReactActivity {
67+
68+
@Override
69+
protected String getMainComponentName() {
70+
return "Example";
71+
}
72+
73+
+ @Override
74+
+ protected ReactActivityDelegate createReactActivityDelegate() {
75+
+ return new ReactActivityDelegate(this, getMainComponentName()) {
76+
+ @Override
77+
+ protected ReactRootView createRootView() {
78+
+ return new RNGestureHandlerEnabledRootView(MainActivity.this);
79+
+ }
80+
+ };
81+
+ }
82+
}
83+
```
84+
85+
Finally, run `react-native run-android` or `react-native run-ios` to launch the app on your device/simulator.
5786

5887
## API Definition
5988

0 commit comments

Comments
 (0)