From f3abca6462adfc9dc320dd805257a2bcf64a5e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 30 Jan 2019 16:31:30 +0100 Subject: [PATCH] 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. --- ios/app/src/AppDelegate.m | 5 +++-- ios/sdk/src/JitsiMeet.h | 3 +++ ios/sdk/src/JitsiMeet.m | 19 ++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ios/app/src/AppDelegate.m b/ios/app/src/AppDelegate.m index d263cb0ae..ee0b3c77c 100644 --- a/ios/app/src/AppDelegate.m +++ b/ios/app/src/AppDelegate.m @@ -37,9 +37,10 @@ [Fabric with:@[[Crashlytics class]]]; } - // Set the conference activity type defined in this application. - // This cannot be defined by the SDK. [JitsiMeet sharedInstance].conferenceActivityType = JitsiMeetConferenceActivityType; + [JitsiMeet sharedInstance].customUrlScheme = @"org.jitsi.meet"; + [JitsiMeet sharedInstance].universalLinkDomains = @[@"meet.jit.si", @"beta.meet.jit.si"]; + [[JitsiMeet sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; return YES; diff --git a/ios/sdk/src/JitsiMeet.h b/ios/sdk/src/JitsiMeet.h index a31670967..447d392d6 100644 --- a/ios/sdk/src/JitsiMeet.h +++ b/ios/sdk/src/JitsiMeet.h @@ -18,9 +18,12 @@ #import #import + @interface JitsiMeet : NSObject @property (copy, nonatomic, nullable) NSString *conferenceActivityType; +@property (copy, nonatomic, nullable) NSString *customUrlScheme; +@property (copy, nonatomic, nullable) NSArray *universalLinkDomains; #pragma mak - This class is a singleton diff --git a/ios/sdk/src/JitsiMeet.m b/ios/sdk/src/JitsiMeet.m index 69761e0a9..034b00c2b 100644 --- a/ios/sdk/src/JitsiMeet.m +++ b/ios/sdk/src/JitsiMeet.m @@ -91,6 +91,10 @@ return YES; } + if (![_customUrlScheme isEqualToString:url.scheme]) { + return NO; + } + return [JitsiMeetView loadURLInViews:@{ @"url" : url.absoluteString }]; } @@ -118,7 +122,10 @@ if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) { // App was started by opening a URL in the browser - return @{ @"url" : userActivity.webpageURL.absoluteString }; + NSURL *url = userActivity.webpageURL; + if ([_universalLinkDomains containsObject:url.host]) { + return @{ @"url" : url.absoluteString }; + } } else if ([activityType isEqualToString:@"INStartAudioCallIntent"] || [activityType isEqualToString:@"INStartVideoCallIntent"]) { // App was started by a CallKit Intent @@ -152,6 +159,16 @@ return nil; } +#pragma mark - Property getter / setters + +- (NSString *)customUrlScheme { + return _customUrlScheme ? _customUrlScheme : @"org.jitsi.meet"; +} + +- (NSArray *)universalLinkDomains { + return _universalLinkDomains ? _universalLinkDomains : @[@"meet.jit.si"]; +} + #pragma mark - Private API methods - (RCTBridge *)getReactBridge {