|
@@ -0,0 +1,83 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright @ 2018-present Atlassian Pty Ltd
|
|
3
|
+ *
|
|
4
|
+ * Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+ * you may not use this file 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
|
+#import <Intents/Intents.h>
|
|
18
|
+
|
|
19
|
+#import <React/RCTBridge.h>
|
|
20
|
+#import <React/RCTBridgeModule.h>
|
|
21
|
+
|
|
22
|
+@interface LaunchOptions : NSObject<RCTBridgeModule>
|
|
23
|
+
|
|
24
|
+@property (nonatomic, weak) RCTBridge *bridge;
|
|
25
|
+
|
|
26
|
+@end
|
|
27
|
+
|
|
28
|
+@implementation LaunchOptions
|
|
29
|
+
|
|
30
|
+RCT_EXPORT_MODULE();
|
|
31
|
+
|
|
32
|
+- (dispatch_queue_t)methodQueue {
|
|
33
|
+ return dispatch_get_main_queue();
|
|
34
|
+}
|
|
35
|
+
|
|
36
|
+RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve
|
|
37
|
+ reject:(__unused RCTPromiseRejectBlock)reject) {
|
|
38
|
+ id initialURL = nil;
|
|
39
|
+ if (self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey]) {
|
|
40
|
+ NSURL *url = self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
|
|
41
|
+ initialURL = url.absoluteString;
|
|
42
|
+ } else {
|
|
43
|
+ NSDictionary *userActivityDictionary
|
|
44
|
+ = self.bridge.launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey];
|
|
45
|
+ NSUserActivity *userActivity
|
|
46
|
+ = [userActivityDictionary objectForKey:@"UIApplicationLaunchOptionsUserActivityKey"];
|
|
47
|
+ if (userActivity != nil) {
|
|
48
|
+ NSString *activityType = userActivity.activityType;
|
|
49
|
+
|
|
50
|
+ if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
|
|
51
|
+ // App was started by opening a URL in the browser
|
|
52
|
+ initialURL = userActivity.webpageURL.absoluteString;
|
|
53
|
+ } else if ([activityType isEqualToString:@"INStartAudioCallIntent"]
|
|
54
|
+ || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
|
|
55
|
+ // App was started by a CallKit Intent
|
|
56
|
+ INIntent *intent = userActivity.interaction.intent;
|
|
57
|
+ NSArray<INPerson *> *contacts;
|
|
58
|
+ NSString *url;
|
|
59
|
+ BOOL startAudioOnly = NO;
|
|
60
|
+
|
|
61
|
+ if ([intent isKindOfClass:[INStartAudioCallIntent class]]) {
|
|
62
|
+ contacts = ((INStartAudioCallIntent *) intent).contacts;
|
|
63
|
+ startAudioOnly = YES;
|
|
64
|
+ } else if ([intent isKindOfClass:[INStartVideoCallIntent class]]) {
|
|
65
|
+ contacts = ((INStartVideoCallIntent *) intent).contacts;
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ if (contacts && (url = contacts.firstObject.personHandle.value)) {
|
|
69
|
+ initialURL
|
|
70
|
+ = @{
|
|
71
|
+ @"config": @{@"startAudioOnly":@(startAudioOnly)},
|
|
72
|
+ @"url": url
|
|
73
|
+ };
|
|
74
|
+ }
|
|
75
|
+ }
|
|
76
|
+ }
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+ resolve(initialURL != nil ? initialURL : (id)kCFNull);
|
|
80
|
+}
|
|
81
|
+
|
|
82
|
+@end
|
|
83
|
+
|