Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

[iOS] Simplify code

Saúl Ibarra Corretgé4898f8159674
diff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.m
index 658d44585d..776fafa41d 100644
--- a/ios/sdk/src/JitsiMeetView.m
+++ b/ios/sdk/src/JitsiMeetView.m
@@ -120,44 +120,16 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler
{
- NSString *activityType = userActivity.activityType;
-
// XXX At least twice we received bug reports about malfunctioning loadURL
// in the Jitsi Meet SDK while the Jitsi Meet app seemed to functioning as
// expected in our testing. But that was to be expected because the app does
// not exercise loadURL. In order to increase the test coverage of loadURL,
// channel Universal linking through loadURL.
- if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]
- && [self loadURLInViews:userActivity.webpageURL]) {
- return YES;
- }
- // Check for a CallKit intent.
- if ([activityType isEqualToString:@"INStartAudioCallIntent"]
- || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
- INIntent *intent = userActivity.interaction.intent;
- NSArray<INPerson *> *contacts;
- NSString *url;
- BOOL startAudioOnly = NO;
+ id url = [self conferenceURLFromUserActivity:userActivity];
- if ([intent isKindOfClass:[INStartAudioCallIntent class]]) {
- contacts = ((INStartAudioCallIntent *) intent).contacts;
- startAudioOnly = YES;
- } else if ([intent isKindOfClass:[INStartVideoCallIntent class]]) {
- contacts = ((INStartVideoCallIntent *) intent).contacts;
- }
-
- if (contacts && (url = contacts.firstObject.personHandle.value)) {
- // Load the URL contained in the handle.
- [self loadURLObjectInViews:@{
- @"config": @{
- @"startAudioOnly": @(startAudioOnly)
- },
- @"url": url
- }];
-
- return YES;
- }
+ if (url && [self loadURLObjectInViews:url]) {
+ return YES;
}
return [RCTLinkingManager application:application
@@ -359,6 +331,38 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
return handled;
}
++ (NSDictionary *)conferenceURLFromUserActivity:(NSUserActivity *)userActivity {
+ NSString *activityType = userActivity.activityType;
+
+ if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
+ // App was started by opening a URL in the browser
+ return @{ @"url" : userActivity.webpageURL.absoluteString };
+ } else if ([activityType isEqualToString:@"INStartAudioCallIntent"]
+ || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
+ // App was started by a CallKit Intent
+ INIntent *intent = userActivity.interaction.intent;
+ NSArray<INPerson *> *contacts;
+ NSString *url;
+ BOOL startAudioOnly = NO;
+
+ if ([intent isKindOfClass:[INStartAudioCallIntent class]]) {
+ contacts = ((INStartAudioCallIntent *) intent).contacts;
+ startAudioOnly = YES;
+ } else if ([intent isKindOfClass:[INStartVideoCallIntent class]]) {
+ contacts = ((INStartVideoCallIntent *) intent).contacts;
+ }
+
+ if (contacts && (url = contacts.firstObject.personHandle.value)) {
+ return @{
+ @"config": @{@"startAudioOnly":@(startAudioOnly)},
+ @"url": url
+ };
+ }
+ }
+
+ return nil;
+}
+
+ (instancetype)viewForExternalAPIScope:(NSString *)externalAPIScope {
return [views objectForKey:externalAPIScope];
}
diff --git a/ios/sdk/src/LaunchOptions.m b/ios/sdk/src/LaunchOptions.m
index 578328c94e..decf2dd68d 100644
--- a/ios/sdk/src/LaunchOptions.m
+++ b/ios/sdk/src/LaunchOptions.m
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#import <Intents/Intents.h>
+#import "JitsiMeetView+Private.h"
#import <React/RCTBridge.h>
#import <React/RCTBridgeModule.h>
@@ -36,6 +36,7 @@ RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve
reject:(__unused RCTPromiseRejectBlock)reject) {
id initialURL = nil;
+
if (self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey]) {
NSURL *url = self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
initialURL = url.absoluteString;
@@ -45,34 +46,7 @@ RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve
NSUserActivity *userActivity
= [userActivityDictionary objectForKey:@"UIApplicationLaunchOptionsUserActivityKey"];
if (userActivity != nil) {
- NSString *activityType = userActivity.activityType;
-
- if ([activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
- // App was started by opening a URL in the browser
- initialURL = userActivity.webpageURL.absoluteString;
- } else if ([activityType isEqualToString:@"INStartAudioCallIntent"]
- || [activityType isEqualToString:@"INStartVideoCallIntent"]) {
- // App was started by a CallKit Intent
- INIntent *intent = userActivity.interaction.intent;
- NSArray<INPerson *> *contacts;
- NSString *url;
- BOOL startAudioOnly = NO;
-
- if ([intent isKindOfClass:[INStartAudioCallIntent class]]) {
- contacts = ((INStartAudioCallIntent *) intent).contacts;
- startAudioOnly = YES;
- } else if ([intent isKindOfClass:[INStartVideoCallIntent class]]) {
- contacts = ((INStartVideoCallIntent *) intent).contacts;
- }
-
- if (contacts && (url = contacts.firstObject.personHandle.value)) {
- initialURL
- = @{
- @"config": @{@"startAudioOnly":@(startAudioOnly)},
- @"url": url
- };
- }
- }
+ initialURL = [JitsiMeetView conferenceURLFromUserActivity:userActivity];
}
}
@@ -80,4 +54,3 @@ RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve
}
@end
-