@ohos-ports/react-native-firebase-dynamic-links 0.0.0-stage → 22.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +971 -0
- package/LICENSE +32 -0
- package/README.md +53 -2
- package/RNFBDynamicLinks.podspec +49 -0
- package/android/.editorconfig +10 -0
- package/android/build.gradle +98 -0
- package/android/lint.xml +5 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/io/invertase/firebase/dynamiclinks/ReactNativeFirebaseDynamicLinksModule.java +507 -0
- package/android/src/main/java/io/invertase/firebase/dynamiclinks/ReactNativeFirebaseDynamicLinksPackage.java +44 -0
- package/app.plugin.js +1 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.h +37 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.m +132 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.h +28 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m +443 -0
- package/ios/RNFBDynamicLinks.xcodeproj/project.pbxproj +354 -0
- package/ios/RNFBDynamicLinks.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
- package/lib/builder.js +93 -0
- package/lib/builders/analytics.js +61 -0
- package/lib/builders/android.js +52 -0
- package/lib/builders/ios.js +76 -0
- package/lib/builders/itunes.js +49 -0
- package/lib/builders/navigation.js +37 -0
- package/lib/builders/otherPlatform.js +20 -0
- package/lib/builders/social.js +49 -0
- package/lib/index.d.ts +650 -0
- package/lib/index.js +119 -0
- package/lib/modular/index.d.ts +148 -0
- package/lib/modular/index.js +110 -0
- package/lib/version.js +2 -0
- package/package.json +42 -4
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +17 -0
- package/plugin/build/ios/appDelegate.d.ts +5 -0
- package/plugin/build/ios/appDelegate.js +86 -0
- package/plugin/build/ios/index.d.ts +2 -0
- package/plugin/build/ios/index.js +13 -0
- package/plugin/src/index.ts +15 -0
- package/plugin/src/ios/appDelegate.ts +92 -0
- package/plugin/src/ios/index.ts +3 -0
- package/plugin/tsconfig.json +9 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#import "RNFBDynamicLinksAppDelegateInterceptor.h"
|
|
19
|
+
#import <GoogleUtilities/GULAppDelegateSwizzler.h>
|
|
20
|
+
#import <RNFBApp/RNFBRCTEventEmitter.h>
|
|
21
|
+
|
|
22
|
+
@implementation RNFBDynamicLinksAppDelegateInterceptor
|
|
23
|
+
|
|
24
|
+
+ (instancetype)sharedInstance {
|
|
25
|
+
static dispatch_once_t once;
|
|
26
|
+
static RNFBDynamicLinksAppDelegateInterceptor *sharedInstance;
|
|
27
|
+
dispatch_once(&once, ^{
|
|
28
|
+
sharedInstance = [[RNFBDynamicLinksAppDelegateInterceptor alloc] init];
|
|
29
|
+
sharedInstance.initialLinkUrl = nil;
|
|
30
|
+
sharedInstance.initialLinkMinimumAppVersion = nil;
|
|
31
|
+
sharedInstance.initialLinkUtmParametersDictionary = @{};
|
|
32
|
+
[GULAppDelegateSwizzler proxyOriginalDelegate];
|
|
33
|
+
[GULAppDelegateSwizzler registerAppDelegateInterceptor:sharedInstance];
|
|
34
|
+
});
|
|
35
|
+
return sharedInstance;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (BOOL)application:(UIApplication *)app
|
|
39
|
+
openURL:(NSURL *)url
|
|
40
|
+
options:(NSDictionary<NSString *, id> *)options {
|
|
41
|
+
FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
|
|
42
|
+
|
|
43
|
+
if (!dynamicLink) {
|
|
44
|
+
dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromUniversalLinkURL:url];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!dynamicLink) {
|
|
48
|
+
return NO;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (dynamicLink.url) {
|
|
52
|
+
if (_initialLinkUrl == nil) {
|
|
53
|
+
_initialLinkUrl = dynamicLink.url.absoluteString;
|
|
54
|
+
_initialLinkMinimumAppVersion = dynamicLink.minimumAppVersion;
|
|
55
|
+
_initialLinkUtmParametersDictionary = dynamicLink.utmParametersDictionary;
|
|
56
|
+
}
|
|
57
|
+
[[RNFBRCTEventEmitter shared]
|
|
58
|
+
sendEventWithName:LINK_RECEIVED_EVENT
|
|
59
|
+
body:@{
|
|
60
|
+
@"url" : dynamicLink.url.absoluteString,
|
|
61
|
+
@"minimumAppVersion" : dynamicLink.minimumAppVersion == nil
|
|
62
|
+
? [NSNull null]
|
|
63
|
+
: dynamicLink.minimumAppVersion,
|
|
64
|
+
@"utmParameters" : dynamicLink.utmParametersDictionary == nil
|
|
65
|
+
? @{}
|
|
66
|
+
: dynamicLink.utmParametersDictionary,
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// results of this are ORed and NO doesn't affect other delegate interceptors' result
|
|
71
|
+
return NO;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#pragma mark - User Activities overridden handler methods
|
|
75
|
+
|
|
76
|
+
- (BOOL)application:(UIApplication *)application
|
|
77
|
+
continueUserActivity:(NSUserActivity *)userActivity
|
|
78
|
+
restorationHandler:
|
|
79
|
+
(void (^_Nonnull __strong)(NSArray<id<UIUserActivityRestoring>>
|
|
80
|
+
*_Nullable __strong restorableObjects))restorationHandler {
|
|
81
|
+
__block BOOL retried = NO;
|
|
82
|
+
|
|
83
|
+
id completion = ^(FIRDynamicLink *_Nullable dynamicLink, NSError *_Nullable error) {
|
|
84
|
+
if (!error && dynamicLink && dynamicLink.url) {
|
|
85
|
+
if (self->_initialLinkUrl == nil) {
|
|
86
|
+
self->_initialLinkUrl = dynamicLink.url.absoluteString;
|
|
87
|
+
self->_initialLinkMinimumAppVersion = dynamicLink.minimumAppVersion;
|
|
88
|
+
self->_initialLinkUtmParametersDictionary = dynamicLink.utmParametersDictionary;
|
|
89
|
+
}
|
|
90
|
+
[[RNFBRCTEventEmitter shared]
|
|
91
|
+
sendEventWithName:LINK_RECEIVED_EVENT
|
|
92
|
+
body:@{
|
|
93
|
+
@"url" : dynamicLink.url.absoluteString,
|
|
94
|
+
@"minimumAppVersion" : dynamicLink.minimumAppVersion == nil
|
|
95
|
+
? [NSNull null]
|
|
96
|
+
: dynamicLink.minimumAppVersion,
|
|
97
|
+
@"utmParameters" : dynamicLink.utmParametersDictionary == nil
|
|
98
|
+
? @{}
|
|
99
|
+
: dynamicLink.utmParametersDictionary,
|
|
100
|
+
}];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Per Apple Tech Support, a network failure could occur when returning from background on
|
|
104
|
+
// iOS 12. https://github.com/AFNetworking/AFNetworking/issues/4279#issuecomment-447108981 So
|
|
105
|
+
// we'll retry the request once
|
|
106
|
+
if (error && !retried && [NSPOSIXErrorDomain isEqualToString:error.domain] &&
|
|
107
|
+
error.code == 53) {
|
|
108
|
+
retried = YES;
|
|
109
|
+
[[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
|
|
110
|
+
completion:completion];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// TODO: We could send this to JS and maybe have a onDynamicLinkError listener but there's also
|
|
114
|
+
// a good chance the
|
|
115
|
+
// TODO: `userActivity.webpageURL` might not be for a Firebase dynamic link, which needs
|
|
116
|
+
// consideration - so we'll
|
|
117
|
+
// TODO: log this for now, logging will get picked up by Crashlytics automatically if its
|
|
118
|
+
// integrated.
|
|
119
|
+
if (error)
|
|
120
|
+
NSLog(@"RNFBDynamicLinks: Unknown error occurred when attempting to handle a universal link: "
|
|
121
|
+
@"%@",
|
|
122
|
+
error);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
[[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
|
|
126
|
+
completion:completion];
|
|
127
|
+
|
|
128
|
+
// results of this are ORed and NO doesn't affect other delegate interceptors' result
|
|
129
|
+
return NO;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#import <Firebase/Firebase.h>
|
|
19
|
+
#import <Foundation/Foundation.h>
|
|
20
|
+
#import <RNFBApp/RNFBSharedUtils.h>
|
|
21
|
+
#import <React/RCTBridgeModule.h>
|
|
22
|
+
#import <React/RCTEventEmitter.h>
|
|
23
|
+
#import <React/RCTUtils.h>
|
|
24
|
+
|
|
25
|
+
// can't access self.bridge.launchOptions without RCTEventEmitter
|
|
26
|
+
@interface RNFBDynamicLinksModule : RCTEventEmitter <RCTBridgeModule>
|
|
27
|
+
|
|
28
|
+
@end
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this library except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#import "RNFBDynamicLinksModule.h"
|
|
19
|
+
#import "RNFBDynamicLinksAppDelegateInterceptor.h"
|
|
20
|
+
|
|
21
|
+
@implementation RNFBDynamicLinksModule
|
|
22
|
+
#pragma mark -
|
|
23
|
+
#pragma mark Module Setup
|
|
24
|
+
|
|
25
|
+
RCT_EXPORT_MODULE();
|
|
26
|
+
|
|
27
|
+
@synthesize bridge = _bridge;
|
|
28
|
+
|
|
29
|
+
#pragma mark -
|
|
30
|
+
#pragma mark Firebase Links Methods
|
|
31
|
+
|
|
32
|
+
// required to init app delegate interceptor as early as possible
|
|
33
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
34
|
+
return YES;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (id)init {
|
|
38
|
+
self = [super init];
|
|
39
|
+
static dispatch_once_t onceToken;
|
|
40
|
+
dispatch_once(&onceToken, ^{
|
|
41
|
+
// access shared instance to initialize app delegate interceptor
|
|
42
|
+
[RNFBDynamicLinksAppDelegateInterceptor sharedInstance];
|
|
43
|
+
});
|
|
44
|
+
return self;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
RCT_EXPORT_METHOD(buildLink
|
|
48
|
+
: (NSDictionary *)dynamicLinkDict
|
|
49
|
+
: (RCTPromiseResolveBlock)resolve
|
|
50
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
51
|
+
FIRDynamicLinkComponents *linkComponents;
|
|
52
|
+
|
|
53
|
+
@try {
|
|
54
|
+
linkComponents = [self createDynamicLinkComponents:dynamicLinkDict];
|
|
55
|
+
} @catch (NSException *exception) {
|
|
56
|
+
DLog(@"Building dynamic link failed %@", exception);
|
|
57
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
58
|
+
userInfo:(NSMutableDictionary *)@{
|
|
59
|
+
@"code" : @"build-failed",
|
|
60
|
+
@"message" : [exception description],
|
|
61
|
+
}];
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!linkComponents || !linkComponents.url) {
|
|
66
|
+
[RNFBSharedUtils
|
|
67
|
+
rejectPromiseWithUserInfo:reject
|
|
68
|
+
userInfo:(NSMutableDictionary *)@{
|
|
69
|
+
@"code" : @"build-failed",
|
|
70
|
+
@"message" : @"Failed to build dynamic link for unknown reason",
|
|
71
|
+
}];
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
resolve(linkComponents.url.absoluteString);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
RCT_EXPORT_METHOD(buildShortLink
|
|
79
|
+
: (NSDictionary *)dynamicLinkDict
|
|
80
|
+
: (NSString *)shortLinkType
|
|
81
|
+
: (RCTPromiseResolveBlock)resolve
|
|
82
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
83
|
+
FIRDynamicLinkComponents *linkComponents;
|
|
84
|
+
|
|
85
|
+
@try {
|
|
86
|
+
linkComponents = [self createDynamicLinkComponents:dynamicLinkDict];
|
|
87
|
+
} @catch (NSException *exception) {
|
|
88
|
+
DLog(@"Building short dynamic link failed %@", exception);
|
|
89
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
90
|
+
userInfo:(NSMutableDictionary *)@{
|
|
91
|
+
@"code" : @"build-failed",
|
|
92
|
+
@"message" : [exception description],
|
|
93
|
+
}];
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
FIRDynamicLinkComponentsOptions *componentsOptions = [FIRDynamicLinkComponentsOptions options];
|
|
98
|
+
|
|
99
|
+
if ([shortLinkType isEqual:@"SHORT"]) {
|
|
100
|
+
componentsOptions.pathLength = FIRShortDynamicLinkPathLengthShort;
|
|
101
|
+
} else if ([shortLinkType isEqual:@"UNGUESSABLE"]) {
|
|
102
|
+
componentsOptions.pathLength = FIRShortDynamicLinkPathLengthUnguessable;
|
|
103
|
+
} else {
|
|
104
|
+
componentsOptions.pathLength = FIRShortDynamicLinkPathLengthDefault;
|
|
105
|
+
}
|
|
106
|
+
linkComponents.options = componentsOptions;
|
|
107
|
+
|
|
108
|
+
[linkComponents shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray *_Nullable warnings,
|
|
109
|
+
NSError *_Nullable error) {
|
|
110
|
+
if (error) {
|
|
111
|
+
DLog(@"Building short dynamic link failed %@", error);
|
|
112
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
113
|
+
userInfo:(NSMutableDictionary *)@{
|
|
114
|
+
@"code" : @"build-failed",
|
|
115
|
+
@"message" : [error localizedDescription],
|
|
116
|
+
}];
|
|
117
|
+
} else {
|
|
118
|
+
resolve(shortURL.absoluteString);
|
|
119
|
+
}
|
|
120
|
+
}];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// TODO refactor to reduce duplication
|
|
124
|
+
RCT_EXPORT_METHOD(getInitialLink
|
|
125
|
+
: (RCTPromiseResolveBlock)resolve
|
|
126
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
127
|
+
NSDictionary *launchOptions = self.bridge.launchOptions;
|
|
128
|
+
|
|
129
|
+
if (launchOptions[UIApplicationLaunchOptionsURLKey]) {
|
|
130
|
+
NSURL *url = (NSURL *)launchOptions[UIApplicationLaunchOptionsURLKey];
|
|
131
|
+
FIRDynamicLink *dynamicLink =
|
|
132
|
+
[[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
|
|
133
|
+
|
|
134
|
+
if (dynamicLink && dynamicLink.url) {
|
|
135
|
+
resolve(@{
|
|
136
|
+
@"url" : dynamicLink.url.absoluteString,
|
|
137
|
+
@"minimumAppVersion" : dynamicLink.minimumAppVersion == nil ? [NSNull null]
|
|
138
|
+
: dynamicLink.minimumAppVersion,
|
|
139
|
+
@"utmParameters" : dynamicLink.utmParametersDictionary == nil
|
|
140
|
+
? @{}
|
|
141
|
+
: dynamicLink.utmParametersDictionary,
|
|
142
|
+
});
|
|
143
|
+
} else if ([RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkUrl != nil) {
|
|
144
|
+
resolve(@{
|
|
145
|
+
@"url" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkUrl,
|
|
146
|
+
@"minimumAppVersion" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
147
|
+
.initialLinkMinimumAppVersion == nil
|
|
148
|
+
? [NSNull null]
|
|
149
|
+
: [RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkMinimumAppVersion,
|
|
150
|
+
@"utmParameters" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
151
|
+
.initialLinkUtmParametersDictionary == nil
|
|
152
|
+
? @{}
|
|
153
|
+
: [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
154
|
+
.initialLinkUtmParametersDictionary,
|
|
155
|
+
});
|
|
156
|
+
} else {
|
|
157
|
+
resolve([NSNull null]);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
NSDictionary *userActivityDict =
|
|
164
|
+
launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];
|
|
165
|
+
if (userActivityDict && [userActivityDict[UIApplicationLaunchOptionsUserActivityTypeKey]
|
|
166
|
+
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
|
|
167
|
+
NSUserActivity *userActivity =
|
|
168
|
+
(NSUserActivity *)userActivityDict[@"UIApplicationLaunchOptionsUserActivityKey"];
|
|
169
|
+
|
|
170
|
+
id completion = ^(FIRDynamicLink *_Nullable dynamicLink, NSError *_Nullable error) {
|
|
171
|
+
if (!error && dynamicLink && dynamicLink.url) {
|
|
172
|
+
resolve(@{
|
|
173
|
+
@"url" : dynamicLink.url.absoluteString,
|
|
174
|
+
@"minimumAppVersion" : dynamicLink.minimumAppVersion == nil
|
|
175
|
+
? [NSNull null]
|
|
176
|
+
: dynamicLink.minimumAppVersion,
|
|
177
|
+
@"utmParameters" : dynamicLink.utmParametersDictionary == nil
|
|
178
|
+
? @{}
|
|
179
|
+
: dynamicLink.utmParametersDictionary,
|
|
180
|
+
});
|
|
181
|
+
} else if (!error &&
|
|
182
|
+
[RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkUrl != nil) {
|
|
183
|
+
resolve(@{
|
|
184
|
+
@"url" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkUrl,
|
|
185
|
+
@"minimumAppVersion" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
186
|
+
.initialLinkMinimumAppVersion == nil
|
|
187
|
+
? [NSNull null]
|
|
188
|
+
: [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
189
|
+
.initialLinkMinimumAppVersion,
|
|
190
|
+
@"utmParameters" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
191
|
+
.initialLinkUtmParametersDictionary == nil
|
|
192
|
+
? @{}
|
|
193
|
+
: [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
194
|
+
.initialLinkUtmParametersDictionary,
|
|
195
|
+
});
|
|
196
|
+
} else if (error) {
|
|
197
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
198
|
+
userInfo:(NSMutableDictionary *)@{
|
|
199
|
+
@"code" : @"initial-link-error",
|
|
200
|
+
@"message" : [error localizedDescription],
|
|
201
|
+
}];
|
|
202
|
+
} else {
|
|
203
|
+
resolve([NSNull null]);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
[[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
|
|
208
|
+
completion:completion];
|
|
209
|
+
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if ([RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkUrl != nil) {
|
|
214
|
+
resolve(@{
|
|
215
|
+
@"url" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkUrl,
|
|
216
|
+
@"minimumAppVersion" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
217
|
+
.initialLinkMinimumAppVersion == nil
|
|
218
|
+
? [NSNull null]
|
|
219
|
+
: [RNFBDynamicLinksAppDelegateInterceptor sharedInstance].initialLinkMinimumAppVersion,
|
|
220
|
+
@"utmParameters" : [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
221
|
+
.initialLinkUtmParametersDictionary == nil
|
|
222
|
+
? @{}
|
|
223
|
+
: [RNFBDynamicLinksAppDelegateInterceptor sharedInstance]
|
|
224
|
+
.initialLinkUtmParametersDictionary,
|
|
225
|
+
});
|
|
226
|
+
} else {
|
|
227
|
+
resolve([NSNull null]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
RCT_EXPORT_METHOD(performDiagnostics) { [FIRDynamicLinks performDiagnosticsWithCompletion:nil]; }
|
|
232
|
+
|
|
233
|
+
RCT_EXPORT_METHOD(resolveLink
|
|
234
|
+
: (NSString *)link
|
|
235
|
+
: (RCTPromiseResolveBlock)resolve
|
|
236
|
+
: (RCTPromiseRejectBlock)reject) {
|
|
237
|
+
id completion = ^(FIRDynamicLink *_Nullable dynamicLink, NSError *_Nullable error) {
|
|
238
|
+
if (!error && dynamicLink && dynamicLink.url) {
|
|
239
|
+
resolve(@{
|
|
240
|
+
@"url" : dynamicLink.url.absoluteString,
|
|
241
|
+
@"minimumAppVersion" : dynamicLink.minimumAppVersion == nil ? [NSNull null]
|
|
242
|
+
: dynamicLink.minimumAppVersion,
|
|
243
|
+
@"utmParameters" : dynamicLink.utmParametersDictionary == nil
|
|
244
|
+
? @{}
|
|
245
|
+
: dynamicLink.utmParametersDictionary,
|
|
246
|
+
});
|
|
247
|
+
} else if (!error ||
|
|
248
|
+
(error && [error.localizedDescription containsString:@"dynamicLinks error 404"])) {
|
|
249
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
250
|
+
userInfo:(NSMutableDictionary *)@{
|
|
251
|
+
@"code" : @"not-found",
|
|
252
|
+
@"message" : @"Dynamic link not found"
|
|
253
|
+
}];
|
|
254
|
+
} else {
|
|
255
|
+
[RNFBSharedUtils rejectPromiseWithUserInfo:reject
|
|
256
|
+
userInfo:(NSMutableDictionary *)@{
|
|
257
|
+
@"code" : @"resolve-link-error",
|
|
258
|
+
@"message" : [error localizedDescription]
|
|
259
|
+
}];
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
[[FIRDynamicLinks dynamicLinks] handleUniversalLink:[NSURL URLWithString:link]
|
|
264
|
+
completion:completion];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
- (FIRDynamicLinkComponents *)createDynamicLinkComponents:(NSDictionary *)dynamicLinkDict {
|
|
268
|
+
NSURL *link = [NSURL URLWithString:dynamicLinkDict[@"link"]];
|
|
269
|
+
FIRDynamicLinkComponents *linkComponents =
|
|
270
|
+
[FIRDynamicLinkComponents componentsWithLink:link
|
|
271
|
+
domainURIPrefix:dynamicLinkDict[@"domainUriPrefix"]];
|
|
272
|
+
|
|
273
|
+
[self buildAnalyticsParameters:dynamicLinkDict[@"analytics"] components:linkComponents];
|
|
274
|
+
[self buildAndroidParameters:dynamicLinkDict[@"android"] components:linkComponents];
|
|
275
|
+
[self buildIosParameters:dynamicLinkDict[@"ios"] components:linkComponents];
|
|
276
|
+
[self buildItunesParameters:dynamicLinkDict[@"itunes"] components:linkComponents];
|
|
277
|
+
[self buildNavigationParameters:dynamicLinkDict[@"navigation"] components:linkComponents];
|
|
278
|
+
[self buildSocialParameters:dynamicLinkDict[@"social"] components:linkComponents];
|
|
279
|
+
[self buildOtherPlatformParameters:dynamicLinkDict[@"otherPlatform"] components:linkComponents];
|
|
280
|
+
|
|
281
|
+
return linkComponents;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
- (void)buildAnalyticsParameters:(NSDictionary *)analyticsDict
|
|
285
|
+
components:(FIRDynamicLinkComponents *)linkComponents {
|
|
286
|
+
if (analyticsDict == nil) return;
|
|
287
|
+
|
|
288
|
+
FIRDynamicLinkGoogleAnalyticsParameters *analyticsParams =
|
|
289
|
+
[FIRDynamicLinkGoogleAnalyticsParameters parameters];
|
|
290
|
+
|
|
291
|
+
if (analyticsDict[@"campaign"]) {
|
|
292
|
+
analyticsParams.campaign = analyticsDict[@"campaign"];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (analyticsDict[@"content"]) {
|
|
296
|
+
analyticsParams.content = analyticsDict[@"content"];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (analyticsDict[@"medium"]) {
|
|
300
|
+
analyticsParams.medium = analyticsDict[@"medium"];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (analyticsDict[@"source"]) {
|
|
304
|
+
analyticsParams.source = analyticsDict[@"source"];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (analyticsDict[@"term"]) {
|
|
308
|
+
analyticsParams.term = analyticsDict[@"term"];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
linkComponents.analyticsParameters = analyticsParams;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
- (void)buildAndroidParameters:(NSDictionary *)androidDict
|
|
315
|
+
components:(FIRDynamicLinkComponents *)linkComponents {
|
|
316
|
+
if (androidDict == nil) return;
|
|
317
|
+
|
|
318
|
+
FIRDynamicLinkAndroidParameters *androidParams =
|
|
319
|
+
[FIRDynamicLinkAndroidParameters parametersWithPackageName:androidDict[@"packageName"]];
|
|
320
|
+
|
|
321
|
+
if (androidDict[@"fallbackUrl"]) {
|
|
322
|
+
androidParams.fallbackURL = [NSURL URLWithString:androidDict[@"fallbackUrl"]];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (androidDict[@"minimumVersion"]) {
|
|
326
|
+
androidParams.minimumVersion = [androidDict[@"minimumVersion"] integerValue];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
linkComponents.androidParameters = androidParams;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
- (void)buildIosParameters:(NSDictionary *)iosDict
|
|
333
|
+
components:(FIRDynamicLinkComponents *)linkComponents {
|
|
334
|
+
if (iosDict == nil) return;
|
|
335
|
+
|
|
336
|
+
FIRDynamicLinkIOSParameters *iOSParams =
|
|
337
|
+
[FIRDynamicLinkIOSParameters parametersWithBundleID:iosDict[@"bundleId"]];
|
|
338
|
+
|
|
339
|
+
if (iosDict[@"appStoreId"]) {
|
|
340
|
+
iOSParams.appStoreID = iosDict[@"appStoreId"];
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (iosDict[@"customScheme"]) {
|
|
344
|
+
iOSParams.customScheme = iosDict[@"customScheme"];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (iosDict[@"fallbackUrl"]) {
|
|
348
|
+
iOSParams.fallbackURL = [NSURL URLWithString:iosDict[@"fallbackUrl"]];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (iosDict[@"iPadBundleId"]) {
|
|
352
|
+
iOSParams.iPadBundleID = iosDict[@"iPadBundleId"];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (iosDict[@"iPadFallbackUrl"]) {
|
|
356
|
+
iOSParams.iPadFallbackURL = [NSURL URLWithString:iosDict[@"iPadFallbackUrl"]];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (iosDict[@"minimumVersion"]) {
|
|
360
|
+
iOSParams.minimumAppVersion = iosDict[@"minimumVersion"];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
linkComponents.iOSParameters = iOSParams;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
- (void)buildItunesParameters:(NSDictionary *)itunesDict
|
|
367
|
+
components:(FIRDynamicLinkComponents *)linkComponents {
|
|
368
|
+
if (itunesDict == nil) return;
|
|
369
|
+
|
|
370
|
+
FIRDynamicLinkItunesConnectAnalyticsParameters *itunesParams =
|
|
371
|
+
[FIRDynamicLinkItunesConnectAnalyticsParameters parameters];
|
|
372
|
+
|
|
373
|
+
if (itunesDict[@"affiliateToken"]) {
|
|
374
|
+
itunesParams.affiliateToken = itunesDict[@"affiliateToken"];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (itunesDict[@"campaignToken"]) {
|
|
378
|
+
itunesParams.campaignToken = itunesDict[@"campaignToken"];
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (itunesDict[@"providerToken"]) {
|
|
382
|
+
itunesParams.providerToken = itunesDict[@"providerToken"];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
linkComponents.iTunesConnectParameters = itunesParams;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
- (void)buildNavigationParameters:(NSDictionary *)navigationDict
|
|
389
|
+
components:(FIRDynamicLinkComponents *)linkComponents {
|
|
390
|
+
if (navigationDict == nil) return;
|
|
391
|
+
|
|
392
|
+
FIRDynamicLinkNavigationInfoParameters *navigationParams =
|
|
393
|
+
[FIRDynamicLinkNavigationInfoParameters parameters];
|
|
394
|
+
|
|
395
|
+
if (navigationDict[@"forcedRedirectEnabled"]) {
|
|
396
|
+
navigationParams.forcedRedirectEnabled = [navigationDict[@"forcedRedirectEnabled"] boolValue];
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
linkComponents.navigationInfoParameters = navigationParams;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
- (void)buildSocialParameters:(NSDictionary *)socialDict
|
|
403
|
+
components:(FIRDynamicLinkComponents *)linkComponents {
|
|
404
|
+
if (socialDict == nil) return;
|
|
405
|
+
|
|
406
|
+
FIRDynamicLinkSocialMetaTagParameters *socialParams =
|
|
407
|
+
[FIRDynamicLinkSocialMetaTagParameters parameters];
|
|
408
|
+
if (socialDict[@"descriptionText"]) {
|
|
409
|
+
socialParams.descriptionText = socialDict[@"descriptionText"];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (socialDict[@"imageUrl"]) {
|
|
413
|
+
socialParams.imageURL = [NSURL URLWithString:socialDict[@"imageUrl"]];
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (socialDict[@"title"]) {
|
|
417
|
+
socialParams.title = socialDict[@"title"];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
linkComponents.socialMetaTagParameters = socialParams;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
- (void)buildOtherPlatformParameters:(NSDictionary *)otherDict
|
|
424
|
+
components:(FIRDynamicLinkComponents *)linkComponents {
|
|
425
|
+
if (otherDict == nil) return;
|
|
426
|
+
|
|
427
|
+
FIRDynamicLinkOtherPlatformParameters *otherParams =
|
|
428
|
+
[FIRDynamicLinkOtherPlatformParameters parameters];
|
|
429
|
+
if (otherDict[@"fallbackUrl"]) {
|
|
430
|
+
otherParams.fallbackUrl = [NSURL URLWithString:otherDict[@"fallbackUrl"]];
|
|
431
|
+
}
|
|
432
|
+
linkComponents.otherPlatformParameters = otherParams;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
436
|
+
return @[];
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// TODO document or add a method to call this:
|
|
440
|
+
// [FIRDynamicLinks performDiagnosticsWithCompletion:nil];
|
|
441
|
+
// ref: https://firebase.google.com/docs/dynamic-links/debug#ios_self-diagnostic_tool
|
|
442
|
+
|
|
443
|
+
@end
|