Browse Source

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 years ago
parent
commit
f3abca6462
3 changed files with 24 additions and 3 deletions
  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 View File

@@ -37,9 +37,10 @@
37 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 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 44
     [[JitsiMeet sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
44 45
 
45 46
     return YES;

+ 3
- 0
ios/sdk/src/JitsiMeet.h View File

@@ -18,9 +18,12 @@
18 18
 #import <JitsiMeet/JitsiMeetView.h>
19 19
 #import <JitsiMeet/JitsiMeetViewDelegate.h>
20 20
 
21
+
21 22
 @interface JitsiMeet : NSObject
22 23
 
23 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 28
 #pragma mak - This class is a singleton
26 29
 

+ 18
- 1
ios/sdk/src/JitsiMeet.m View File

@@ -91,6 +91,10 @@
91 91
         return YES;
92 92
     }
93 93
 
94
+    if (![_customUrlScheme isEqualToString:url.scheme]) {
95
+        return NO;
96
+    }
97
+
94 98
     return [JitsiMeetView loadURLInViews:@{ @"url" : url.absoluteString }];
95 99
 }
96 100
 
@@ -118,7 +122,10 @@
118 122
 
119 123
     if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
120 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 129
     } else if ([activityType isEqualToString:@"INStartAudioCallIntent"]
123 130
                || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
124 131
         // App was started by a CallKit Intent
@@ -152,6 +159,16 @@
152 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 172
 #pragma mark - Private API methods
156 173
 
157 174
 - (RCTBridge *)getReactBridge {

Loading…
Cancel
Save