Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[RN] Alternative to JitsiMeetView.loadURL w/o URL
Lyubo Marinova2c2d3bee1fe
diff --git a/android/README.md b/android/README.mdindex b97d49d767..1a8d461cd6 100644--- a/android/README.md+++ b/android/README.md@@ -93,10 +93,6 @@ See JitsiMeetView.getWelcomePageEnabled.See JitsiMeetView.loadURL.-#### loadURLString(String)--See JitsiMeetView.loadURLString.-#### setWelcomePageEnabled(boolean)See JitsiMeetView.setWelcomePageEnabled.@@ -118,12 +114,22 @@ empty view will be rendered when not in a conference. Defaults to false.#### loadURL(URL)Loads a specific URL which may identify a conference to join. If the specified-URL is null, the Welcome page is displayed instead.+URL is null and the Welcome page is enabled, the Welcome page is displayed+instead.#### loadURLString(String)Loads a specific URL which may identify a conference to join. If the specified-URL is null, the Welcome page is displayed instead.+URL is null and the Welcome page is enabled, the Welcome page is displayed+instead.++#### loadURLObject(Bundle)++Loads a specific URL which may identify a conference to join. The URL is+specified in the form of a Bundle of properties which (1) internally are+sufficient to construct a URL (string) while (2) abstracting the specifics of+constructing the URL away from API clients/consumers. If the specified URL is+null and the Welcome page is enabled, the Welcome page is displayed instead.#### setListener(listener)diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.javaindex b05e5c0647..c6db4b360c 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java@@ -233,21 +233,24 @@ public class JitsiMeetView extends FrameLayout {}/**- * Loads a specific URL {@link String} which may identify a conference to- * join. If the specified URL {@code String} is {@code null}, the Welcome- * page is displayed instead.+ * Loads a specific URL which may identify a conference to join. The URL is+ * specified in the form of a {@link Bundle} of properties which (1)+ * internally are sufficient to construct a URL {@code String} while (2)+ * abstracting the specifics of constructing the URL away from API+ * clients/consumers. If the specified URL is {@code null} and the Welcome+ * page is enabled, the Welcome page is displayed instead.*- * @param urlString - The URL {@code String} to load which may identify a- * conference to join.+ * @param urlObject - The URL to load which may identify a conference to+ * join.*/- public void loadURLString(@Nullable String urlString) {+ public void loadURLObject(@Nullable Bundle urlObject) {Bundle props = new Bundle();// externalAPIScopeprops.putString("externalAPIScope", externalAPIScope);// url- if (urlString != null) {- props.putString("url", urlString);+ if (urlObject != null) {+ props.putBundle("url", urlObject);}// welcomePageEnabledprops.putBoolean("welcomePageEnabled", welcomePageEnabled);@@ -266,6 +269,26 @@ public class JitsiMeetView extends FrameLayout {addView(reactRootView);}+ /**+ * Loads a specific URL {@link String} which may identify a conference to+ * join. If the specified URL {@code String} is {@code null}, the Welcome+ * page is displayed instead.+ *+ * @param urlString - The URL {@code String} to load which may identify a+ * conference to join.+ */+ public void loadURLString(@Nullable String urlString) {+ Bundle urlObject;++ if (urlString == null) {+ urlObject = null;+ } else {+ urlObject = new Bundle();+ urlObject.putString("url", urlString);+ }+ loadURLObject(urlObject);+ }+/*** Sets a specific {@link JitsiMeetViewListener} on this* {@code JitsiMeetView}.diff --git a/ios/README.md b/ios/README.mdindex 87ab355686..147970c6c5 100644--- a/ios/README.md+++ b/ios/README.md@@ -20,10 +20,10 @@ To get started:- (void)viewDidLoad {[super viewDidLoad];- JitsiMeetView *view = (JitsiMeetView *) self.view;+ JitsiMeetView *jitsiMeetView = (JitsiMeetView *) self.view;- view.delegate = self;- [view loadURL:nil];+ jitsiMeetView.delegate = self;+ [jitsiMeetView loadURL:nil];}```@@ -46,20 +46,40 @@ NOTE: Must be set before `loadURL:`/`loadURLString:` for it to take effect.#### loadURL:NSURL```objc-[meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];+[jitsiMeetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];```Loads a specific URL which may identify a conference to join. If the specified-URL is `nil`, the Welcome page is displayed instead.+URL is `nil` and the Welcome page is enabled, the Welcome page is displayed+instead.++#### loadURLObject:NSDictionary++```objc+[jitsiMeetView loadURLObject:@{+ @"url": @"https://meet.jit.si/test123",+ @"configOverwrite": @{+ @"startWithAudioMuted": @YES,+ @"startWithVideoMuted": @NO+ }+}];+```++Loads a specific URL which may identify a conference to join. The URL is+specified in the form of an `NSDictionary` of properties which (1) internally+are sufficient to construct a URL (string) while (2) abstracting the specifics+of constructing the URL away from API clients/consumers. If the specified URL is+`nil` and the Welcome page is enabled, the Welcome page is displayed instead.#### loadURLString:NSString```objc-[meetView loadURLString:@"https://meet.jit.si/test123"];+[jitsiMeetView loadURLString:@"https://meet.jit.si/test123"];```Loads a specific URL which may identify a conference to join. If the specified-URL is `nil`, the Welcome page is displayed instead.+URL is `nil` and the Welcome page is enabled, the Welcome page is displayed+instead.#### Universal / deep linkingdiff --git a/ios/sdk/src/JitsiMeetView.h b/ios/sdk/src/JitsiMeetView.hindex 8d6702fc31..f328d8f440 100644--- a/ios/sdk/src/JitsiMeetView.h+++ b/ios/sdk/src/JitsiMeetView.h@@ -39,6 +39,8 @@- (void)loadURL:(NSURL * _Nullable)url;+- (void)loadURLObject:(NSDictionary * _Nullable)urlObject;+- (void)loadURLString:(NSString * _Nullable)urlString;@enddiff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.mindex 21c13078d4..e7d5e2bf2d 100644--- a/ios/sdk/src/JitsiMeetView.m+++ b/ios/sdk/src/JitsiMeetView.m@@ -185,28 +185,25 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;* join.*/- (void)loadURL:(NSURL *)url {- [self loadURLString:(url ? url.absoluteString : nil)];+ [self loadURLString:url ? url.absoluteString : nil];}/**- * Loads a specific URL {@link NSString} which may identify a conference to- * join. If the specified URL {@code NSString} is {@code nil}, the Welcome page- * is displayed instead.+ * Loads a specific URL which may identify a conference to join. The URL is+ * specified in the form of an {@link NSDictionary} of properties which (1)+ * internally are sufficient to construct a URL {@code NSString} while (2)+ * abstracting the specifics of constructing the URL away from API+ * clients/consumers. If the specified URL is {@code nil} and the Welcome page+ * is enabled, the Welcome page is displayed instead.*- * @param urlString - The URL {@code NSString} to load which may identify a- * conference to join.+ * @param urlObject - The URL to load which may identify a conference to join.*/-- (void)loadURLString:(NSString *)urlString {- NSMutableDictionary *props = [[NSMutableDictionary alloc] init];-- // externalAPIScope- [props setObject:externalAPIScope forKey:@"externalAPIScope"];- // url- if (urlString) {- [props setObject:urlString forKey:@"url"];- }- // welcomePageEnabled- [props setObject:@(self.welcomePageEnabled) forKey:@"welcomePageEnabled"];+- (void)loadURLObject:(NSDictionary *)urlObject {+ NSDictionary *props = @{+ @"externalAPIScope": externalAPIScope,+ @"url": urlObject,+ @"welcomePageEnabled": @(self.welcomePageEnabled)+ };if (rootView == nil) {rootView@@ -224,6 +221,18 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;}}+/**+ * Loads a specific URL {@link NSString} which may identify a conference to+ * join. If the specified URL {@code NSString} is {@code nil}, the Welcome page+ * is displayed instead.+ *+ * @param urlString - The URL {@code NSString} to load which may identify a+ * conference to join.+ */+- (void)loadURLString:(NSString *)urlString {+ [self loadURLObject:urlString ? @{ @"url": urlString } : nil];+}+#pragma mark Private methods+ (instancetype)viewForExternalAPIScope:(NSString *)externalAPIScope {diff --git a/react/features/app/components/AbstractApp.js b/react/features/app/components/AbstractApp.jsindex 699639d32a..a3f302d5b4 100644--- a/react/features/app/components/AbstractApp.js+++ b/react/features/app/components/AbstractApp.js@@ -11,6 +11,7 @@ import {} from '../../base/participants';import { RouteRegistry } from '../../base/react';import { MiddlewareRegistry, ReducerRegistry } from '../../base/redux';+import { toURLString } from '../../base/util';import {appNavigate,@@ -52,7 +53,10 @@ export class AbstractApp extends Component {/*** The URL, if any, with which the app was launched.*/- url: React.PropTypes.string+ url: React.PropTypes.oneOfType([+ React.PropTypes.object,+ React.PropTypes.string+ ])};/**@@ -110,7 +114,7 @@ export class AbstractApp extends Component {// If a URL was explicitly specified to this React Component, then open// it; otherwise, use a default.- this._openURL(this.props.url || this._getDefaultURL());+ this._openURL(toURLString(this.props.url) || this._getDefaultURL());}/**@@ -139,9 +143,10 @@ export class AbstractApp extends Component {}// Deal with URL changes.- const { url } = nextProps;+ let { url } = nextProps;- if (this.props.url !== url) {+ url = toURLString(url);+ if (toURLString(this.props.url) !== url) {this._openURL(url || this._getDefaultURL());}}@@ -391,12 +396,12 @@ export class AbstractApp extends Component {/*** Navigates this AbstractApp to (i.e. opens) a specific URL.*- * @param {string} url - The URL to which to navigate this AbstractApp (i.e.- * the URL to open).+ * @param {string|Object} url - The URL to navigate this AbstractApp to+ * (i.e. the URL to open).* @protected* @returns {void}*/_openURL(url) {- this._getStore().dispatch(appNavigate(url));+ this._getStore().dispatch(appNavigate(toURLString(url)));}}diff --git a/react/features/base/util/uri.js b/react/features/base/util/uri.jsindex efb6ee03ef..10047d78ed 100644--- a/react/features/base/util/uri.js+++ b/react/features/base/util/uri.js@@ -262,3 +262,53 @@ export function parseURIString(uri: ?string) {return obj;}++/**+ * Attempts to return a {@code String} representation of a specific+ * {@code Object} which is supposed to represent a URL. Obviously, if a+ * {@code String} is specified, it is returned. If a {@code URL} is specified,+ * its {@code URL#href} is returned. Additionally, an {@code Object} similar to+ * the one accepted by the constructor of Web's ExternalAPI is supported on both+ * mobile/React Native and Web/React.+ *+ * @param {string|Object} obj - The URL to return a {@code String}+ * representation of.+ * @returns {string} - A {@code String} representation of the specified+ * {@code obj} which is supposed to represent a URL.+ */+export function toURLString(obj: ?(string | Object)): ?string {+ let str;++ switch (typeof obj) {+ case 'object':+ if (obj) {+ if (obj instanceof URL) {+ str = obj.href;+ } else {+ str = _urlObjectToString(obj);+ }+ }+ break;++ case 'string':+ str = String(obj);+ break;+ }++ return str;+}++/**+ * Attempts to return a {@code String} representation of a specific+ * {@code Object} similar to the one accepted by the constructor+ * of Web's ExternalAPI.+ *+ * @param {Object} obj - The URL to return a {@code String} representation of.+ * @returns {string} - A {@code String} representation of the specified+ * {@code obj}.+ */+function _urlObjectToString({ url }: Object): ?string {+ // TODO Support properties other than url. Support (pretty much) all+ // properties accepted by the constructor of Web's ExternalAPI.+ return url;+}