浏览代码

ios: add ability to control deep / universal linking

Since the SDK may be embedded with other apps, we need to recognize our custom
URL scheme and universal links in order to tell the user if we will process the
request or not.

Make them configurable with sane defaults.
master
Saúl Ibarra Corretgé 6 年前
父节点
当前提交
f3abca6462
共有 3 个文件被更改,包括 24 次插入3 次删除
  1. 3
    2
      ios/app/src/AppDelegate.m
  2. 3
    0
      ios/sdk/src/JitsiMeet.h
  3. 18
    1
      ios/sdk/src/JitsiMeet.m

+ 3
- 2
ios/app/src/AppDelegate.m 查看文件

37
         [Fabric with:@[[Crashlytics class]]];
37
         [Fabric with:@[[Crashlytics class]]];
38
     }
38
     }
39
 
39
 
40
-    // Set the conference activity type defined in this application.
41
-    // This cannot be defined by the SDK.
42
     [JitsiMeet sharedInstance].conferenceActivityType = JitsiMeetConferenceActivityType;
40
     [JitsiMeet sharedInstance].conferenceActivityType = JitsiMeetConferenceActivityType;
41
+    [JitsiMeet sharedInstance].customUrlScheme = @"org.jitsi.meet";
42
+    [JitsiMeet sharedInstance].universalLinkDomains = @[@"meet.jit.si", @"beta.meet.jit.si"];
43
+
43
     [[JitsiMeet sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
44
     [[JitsiMeet sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
44
 
45
 
45
     return YES;
46
     return YES;

+ 3
- 0
ios/sdk/src/JitsiMeet.h 查看文件

18
 #import <JitsiMeet/JitsiMeetView.h>
18
 #import <JitsiMeet/JitsiMeetView.h>
19
 #import <JitsiMeet/JitsiMeetViewDelegate.h>
19
 #import <JitsiMeet/JitsiMeetViewDelegate.h>
20
 
20
 
21
+
21
 @interface JitsiMeet : NSObject
22
 @interface JitsiMeet : NSObject
22
 
23
 
23
 @property (copy, nonatomic, nullable) NSString *conferenceActivityType;
24
 @property (copy, nonatomic, nullable) NSString *conferenceActivityType;
25
+@property (copy, nonatomic, nullable) NSString *customUrlScheme;
26
+@property (copy, nonatomic, nullable) NSArray<NSString *> *universalLinkDomains;
24
 
27
 
25
 #pragma mak - This class is a singleton
28
 #pragma mak - This class is a singleton
26
 
29
 

+ 18
- 1
ios/sdk/src/JitsiMeet.m 查看文件

91
         return YES;
91
         return YES;
92
     }
92
     }
93
 
93
 
94
+    if (![_customUrlScheme isEqualToString:url.scheme]) {
95
+        return NO;
96
+    }
97
+
94
     return [JitsiMeetView loadURLInViews:@{ @"url" : url.absoluteString }];
98
     return [JitsiMeetView loadURLInViews:@{ @"url" : url.absoluteString }];
95
 }
99
 }
96
 
100
 
118
 
122
 
119
     if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
123
     if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
120
         // App was started by opening a URL in the browser
124
         // App was started by opening a URL in the browser
121
-        return @{ @"url" : userActivity.webpageURL.absoluteString };
125
+        NSURL *url = userActivity.webpageURL;
126
+        if ([_universalLinkDomains containsObject:url.host]) {
127
+            return @{ @"url" : url.absoluteString };
128
+        }
122
     } else if ([activityType isEqualToString:@"INStartAudioCallIntent"]
129
     } else if ([activityType isEqualToString:@"INStartAudioCallIntent"]
123
                || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
130
                || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
124
         // App was started by a CallKit Intent
131
         // App was started by a CallKit Intent
152
     return nil;
159
     return nil;
153
 }
160
 }
154
 
161
 
162
+#pragma mark - Property getter / setters
163
+
164
+- (NSString *)customUrlScheme {
165
+    return _customUrlScheme ? _customUrlScheme : @"org.jitsi.meet";
166
+}
167
+
168
+- (NSArray<NSString *> *)universalLinkDomains {
169
+    return _universalLinkDomains ? _universalLinkDomains : @[@"meet.jit.si"];
170
+}
171
+
155
 #pragma mark - Private API methods
172
 #pragma mark - Private API methods
156
 
173
 
157
 - (RCTBridge *)getReactBridge {
174
 - (RCTBridge *)getReactBridge {

正在加载...
取消
保存