Skip to content

Commit

Permalink
Implement deep-linking (#112)
Browse files Browse the repository at this point in the history
* Minor POC to showcase deep-linking abilities through the boilerplate

* deep linking ios and refactor

Co-authored-by: [email protected] <[email protected]>
Co-authored-by: DOLLE <[email protected]>
Co-authored-by: Aurélien Mutin <[email protected]>
  • Loading branch information
4 people authored Sep 2, 2020
1 parent 6bedcbe commit 7d962ca
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 5 deletions.
16 changes: 16 additions & 0 deletions App/Containers/DeepLinking/DeepLinkingScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react'
import { Text, View } from 'react-native'
import { Helpers, Metrics } from 'App/Theme'

/**
* This is an example of a container component with a deep link.
*/
const DeepLinkingScreen = () => (
<View style={[Helpers.fillCenter, Helpers.rowMain, Metrics.mediumHorizontalMargin]}>
<Text>
This is deep linking example screen which can be accessed using boilerplate://deeplink scheme!
</Text>
</View>
)

export default DeepLinkingScreen
4 changes: 4 additions & 0 deletions App/Containers/Root/RootScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { Helpers } from 'App/Theme'
import { useDispatch } from 'react-redux'

const RootScreen = () => {
// Deep linking prefix
const prefix = 'boilerplate://';

const dispatch = useDispatch()

useEffect(() => {
Expand All @@ -20,6 +23,7 @@ const RootScreen = () => {
ref={(navigatorRef) => {
NavigationService.setTopLevelNavigator(navigatorRef)
}}
uriPrefix={prefix}
/>
</View>
)
Expand Down
9 changes: 8 additions & 1 deletion App/Navigators/AppNavigator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createAppContainer, createStackNavigator } from 'react-navigation'

import ExampleScreen from 'App/Containers/Example/ExampleScreen'
import DeepLinkingScreen from 'App/Containers/DeepLinking/DeepLinkingScreen'
import SplashScreen from 'App/Containers/SplashScreen/SplashScreen'

/**
Expand All @@ -15,7 +16,13 @@ const StackNavigator = createStackNavigator(
SplashScreen: SplashScreen,
// The main application screen is our "ExampleScreen". Feel free to replace it with your
// own screen and remove the example.
MainScreen: ExampleScreen,
MainScreen: {
screen: ExampleScreen,
},
DeepLinkingScreen: {
screen: DeepLinkingScreen,
path: 'deeplink',
},
},
{
// By default the application will show the splash screen
Expand Down
9 changes: 8 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="boilerplate" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
Expand Down
8 changes: 8 additions & 0 deletions ios/Boilerplate/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

#import <React/RCTLinkingManager.h>

#import "AppDelegate.h"

#import <React/RCTBridge.h>
Expand Down Expand Up @@ -39,4 +41,10 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
#endif
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:app openURL:url options:options];
}

@end
15 changes: 14 additions & 1 deletion ios/Boilerplate/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,24 @@
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>boilerplate</string>
<key>CFBundleURLSchemes</key>
<array>
<string>boilerplate</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,6 @@ SPEC CHECKSUMS:
RNScreens: cf198f915f8a2bf163de94ca9f5bfc8d326c3706
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b

PODFILE CHECKSUM: 1aeb3204d81fb1938d1f1a04d0a3797595914ef3
PODFILE CHECKSUM: 3d811d26fadf74812df3c538c7abf505a9be9900

COCOAPODS: 1.9.0
COCOAPODS: 1.9.3

0 comments on commit 7d962ca

Please sign in to comment.