Skip to content
This repository was archived by the owner on May 30, 2022. It is now read-only.

Commit 723bfcb

Browse files
author
Luis Flores
committed
fix(dependencies): Remove react native dependency
BREAKING CHANGE: Event listeners should be declared outside deep-linking
1 parent 0e423ab commit 723bfcb

12 files changed

Lines changed: 782 additions & 1855 deletions

File tree

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["react-native"]
2+
"presets": ["es2015", "stage-2"]
33
}

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,16 @@ DeepLinking.addScheme('example://');
7474
#### 3. Add event listener
7575
```javascript
7676
import { Linking } from 'react-native';
77-
...
78-
Linking.addEventListener('url', DeepLinking.handleUrl);
77+
78+
Linking.addEventListener('url', handleUrl);
79+
80+
const handleUrl = ({ url }) => {
81+
Linking.canOpenURL(url).then((supported) => {
82+
if (supported) {
83+
DeepLinking.evaluateUrl(url);
84+
}
85+
});
86+
};
7987
```
8088

8189
#### 4. Register routes
@@ -113,7 +121,7 @@ export default class App extends Component {
113121

114122
componentDidMount() {
115123
DeepLinking.addScheme('example://');
116-
Linking.addEventListener('url', DeepLinking.handleUrl);
124+
Linking.addEventListener('url', this.handleUrl);
117125

118126
DeepLinking.addRoute('/test', (response) => {
119127
// example://test
@@ -138,7 +146,15 @@ export default class App extends Component {
138146
}
139147

140148
componentWillUnmount() {
141-
Linking.removeEventListener('url', DeepLinking.handleUrl);
149+
Linking.removeEventListener('url', this.handleUrl);
150+
}
151+
152+
handleUrl = ({ url }) => {
153+
Linking.canOpenURL(url).then((supported) => {
154+
if (supported) {
155+
DeepLinking.evaluateUrl(url);
156+
}
157+
});
142158
}
143159

144160
render() {

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@
426426
83CBB9F71A601CBA00E9B192 /* Project object */ = {
427427
isa = PBXProject;
428428
attributes = {
429-
LastUpgradeCheck = 0610;
429+
LastUpgradeCheck = 0820;
430430
ORGANIZATIONNAME = Facebook;
431431
};
432432
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "example" */;
@@ -738,6 +738,7 @@
738738
"-ObjC",
739739
"-lc++",
740740
);
741+
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
741742
PRODUCT_NAME = example;
742743
VERSIONING_SYSTEM = "apple-generic";
743744
};
@@ -755,6 +756,7 @@
755756
"-ObjC",
756757
"-lc++",
757758
);
759+
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
758760
PRODUCT_NAME = example;
759761
VERSIONING_SYSTEM = "apple-generic";
760762
};
@@ -773,15 +775,19 @@
773775
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
774776
CLANG_WARN_EMPTY_BODY = YES;
775777
CLANG_WARN_ENUM_CONVERSION = YES;
778+
CLANG_WARN_INFINITE_RECURSION = YES;
776779
CLANG_WARN_INT_CONVERSION = YES;
777780
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
781+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
778782
CLANG_WARN_UNREACHABLE_CODE = YES;
779783
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
780784
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
781785
COPY_PHASE_STRIP = NO;
782786
ENABLE_STRICT_OBJC_MSGSEND = YES;
787+
ENABLE_TESTABILITY = YES;
783788
GCC_C_LANGUAGE_STANDARD = gnu99;
784789
GCC_DYNAMIC_NO_PIC = NO;
790+
GCC_NO_COMMON_BLOCKS = YES;
785791
GCC_OPTIMIZATION_LEVEL = 0;
786792
GCC_PREPROCESSOR_DEFINITIONS = (
787793
"DEBUG=1",
@@ -814,15 +820,18 @@
814820
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
815821
CLANG_WARN_EMPTY_BODY = YES;
816822
CLANG_WARN_ENUM_CONVERSION = YES;
823+
CLANG_WARN_INFINITE_RECURSION = YES;
817824
CLANG_WARN_INT_CONVERSION = YES;
818825
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
826+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
819827
CLANG_WARN_UNREACHABLE_CODE = YES;
820828
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
821829
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
822830
COPY_PHASE_STRIP = YES;
823831
ENABLE_NS_ASSERTIONS = NO;
824832
ENABLE_STRICT_OBJC_MSGSEND = YES;
825833
GCC_C_LANGUAGE_STANDARD = gnu99;
834+
GCC_NO_COMMON_BLOCKS = YES;
826835
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
827836
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
828837
GCC_WARN_UNDECLARED_SELECTOR = YES;

example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0620"
3+
LastUpgradeVersion = "0820"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

example/ios/example/Info.plist

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +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>CFBundleURLTypes</key>
6-
<array>
7-
<dict>
8-
<key>CFBundleURLSchemes</key>
9-
<array>
10-
<string>example</string>
11-
</array>
12-
</dict>
13-
</array>
145
<key>CFBundleDevelopmentRegion</key>
156
<string>en</string>
167
<key>CFBundleDisplayName</key>
178
<string>Deep Linking</string>
189
<key>CFBundleExecutable</key>
1910
<string>$(EXECUTABLE_NAME)</string>
2011
<key>CFBundleIdentifier</key>
21-
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
2213
<key>CFBundleInfoDictionaryVersion</key>
2314
<string>6.0</string>
2415
<key>CFBundleName</key>
@@ -29,10 +20,32 @@
2920
<string>1.0</string>
3021
<key>CFBundleSignature</key>
3122
<string>????</string>
23+
<key>CFBundleURLTypes</key>
24+
<array>
25+
<dict>
26+
<key>CFBundleURLSchemes</key>
27+
<array>
28+
<string>example</string>
29+
</array>
30+
</dict>
31+
</array>
3232
<key>CFBundleVersion</key>
3333
<string>1</string>
3434
<key>LSRequiresIPhoneOS</key>
3535
<true/>
36+
<key>NSAppTransportSecurity</key>
37+
<dict>
38+
<key>NSExceptionDomains</key>
39+
<dict>
40+
<key>localhost</key>
41+
<dict>
42+
<key>NSExceptionAllowsInsecureHTTPLoads</key>
43+
<true/>
44+
</dict>
45+
</dict>
46+
</dict>
47+
<key>NSLocationWhenInUseUsageDescription</key>
48+
<string></string>
3649
<key>UILaunchStoryboardName</key>
3750
<string>LaunchScreen</string>
3851
<key>UIRequiredDeviceCapabilities</key>
@@ -47,18 +60,5 @@
4760
</array>
4861
<key>UIViewControllerBasedStatusBarAppearance</key>
4962
<false/>
50-
<key>NSLocationWhenInUseUsageDescription</key>
51-
<string></string>
52-
<key>NSAppTransportSecurity</key>
53-
<dict>
54-
<key>NSExceptionDomains</key>
55-
<dict>
56-
<key>localhost</key>
57-
<dict>
58-
<key>NSExceptionAllowsInsecureHTTPLoads</key>
59-
<true/>
60-
</dict>
61-
</dict>
62-
</dict>
6363
</dict>
6464
</plist>

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"dependencies": {
99
"react": "~15.4.2",
10-
"react-native": "0.41.2",
10+
"react-native": "0.42.3",
1111
"react-native-deep-linking": "../"
1212
},
1313
"devDependencies": {

example/src/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class App extends Component {
1010

1111
componentDidMount() {
1212
DeepLinking.addScheme('example://');
13-
Linking.addEventListener('url', DeepLinking.handleUrl);
13+
Linking.addEventListener('url', this.handleUrl);
1414

1515
DeepLinking.addRoute('/test', (response) => {
1616
// example://test
@@ -35,7 +35,15 @@ export default class App extends Component {
3535
}
3636

3737
componentWillUnmount() {
38-
Linking.removeEventListener('url', DeepLinking.handleUrl);
38+
Linking.removeEventListener('url', this.handleUrl);
39+
}
40+
41+
handleUrl = ({ url }) => {
42+
Linking.canOpenURL(url).then((supported) => {
43+
if (supported) {
44+
DeepLinking.evaluateUrl(url);
45+
}
46+
});
3947
}
4048

4149
render() {

0 commit comments

Comments
 (0)