Przeglądaj źródła

[iOS] Fix joining initial URL if app was closed

On iOS, if the app is closed the startup options are only passed as the
`launchOptions` dictionary of `applicationDidFinishLaunching`. Thus add a helper
method to be called from there by embedding applications so we can copy that
dictionary.
master
Saúl Ibarra Corretgé 8 lat temu
rodzic
commit
99b856233d

+ 5
- 4
ios/app/src/AppDelegate.m Wyświetl plik

@@ -22,14 +22,15 @@
22 22
 
23 23
 -             (BOOL)application:(UIApplication *)application
24 24
   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
25
-    return YES;
25
+    return [JitsiMeetView application:application
26
+        didFinishLaunchingWithOptions:launchOptions];
26 27
 }
27 28
 
28 29
 #pragma mark Linking delegate methods
29 30
 
30
--  (BOOL)application:(UIApplication *)application
31
-continueUserActivity:(NSUserActivity *)userActivity
32
-  restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
31
+-    (BOOL)application:(UIApplication *)application
32
+  continueUserActivity:(NSUserActivity *)userActivity
33
+    restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
33 34
     return [JitsiMeetView application:application
34 35
                  continueUserActivity:userActivity
35 36
                    restorationHandler:restorationHandler];

+ 3
- 0
ios/sdk/src/JitsiMeetView.h Wyświetl plik

@@ -25,6 +25,9 @@
25 25
 
26 26
 @property (nonatomic) BOOL welcomePageEnabled;
27 27
 
28
++             (BOOL)application:(UIApplication *_Nonnull)application
29
+  didFinishLaunchingWithOptions:(NSDictionary *_Nonnull)launchOptions;
30
+
28 31
 +    (BOOL)application:(UIApplication * _Nonnull)application
29 32
   continueUserActivity:(NSUserActivity * _Nonnull)userActivity
30 33
     restorationHandler:(void (^ _Nullable)(NSArray * _Nullable))restorationHandler;

+ 20
- 3
ios/sdk/src/JitsiMeetView.m Wyświetl plik

@@ -35,7 +35,8 @@ RCTFatalHandler _RCTFatal = ^(NSError *error) {
35 35
     @try {
36 36
         NSString *name
37 37
             = [NSString stringWithFormat:@"%@: %@",
38
-               RCTFatalExceptionName, error.localizedDescription];
38
+                        RCTFatalExceptionName,
39
+                        error.localizedDescription];
39 40
         NSString *message
40 41
             = RCTFormatError(error.localizedDescription, jsStackTrace, 75);
41 42
         [NSException raise:name format:@"%@", message];
@@ -110,12 +111,27 @@ void registerFatalErrorHandler() {
110 111
 
111 112
 static RCTBridgeWrapper *bridgeWrapper;
112 113
 
114
+/**
115
+ * Copy of the {@code launchOptions} dictionary that the application was started
116
+ * with. It is required for the initial URL to be used if a (Universal) link was
117
+ * used to launch a new instance of the application.
118
+ */
119
+static NSDictionary *_launchOptions;
120
+
113 121
 /**
114 122
  * The {@code JitsiMeetView}s associated with their {@code ExternalAPI} scopes
115 123
  * (i.e. unique identifiers within the process).
116 124
  */
117 125
 static NSMapTable<NSString *, JitsiMeetView *> *views;
118 126
 
127
++             (BOOL)application:(UIApplication *)application
128
+  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
129
+    // Store launch options, will be used when we create the bridge.
130
+    _launchOptions = [launchOptions copy];
131
+
132
+    return YES;
133
+}
134
+
119 135
 #pragma mark Linking delegate helpers
120 136
 // https://facebook.github.io/react-native/docs/linking.html
121 137
 
@@ -201,7 +217,7 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
201 217
 /**
202 218
  * Internal initialization:
203 219
  *
204
- * - sets the backgroudn color
220
+ * - sets the background color
205 221
  * - creates the React bridge
206 222
  * - loads the necessary custom fonts
207 223
  * - registers a custom fatal error error handler for React
@@ -211,7 +227,8 @@ static NSMapTable<NSString *, JitsiMeetView *> *views;
211 227
 
212 228
     dispatch_once(&dispatchOncePredicate, ^{
213 229
         // Initialize the static state of JitsiMeetView.
214
-        bridgeWrapper = [[RCTBridgeWrapper alloc] init];
230
+        bridgeWrapper
231
+            = [[RCTBridgeWrapper alloc] initWithLaunchOptions:_launchOptions];
215 232
         views = [NSMapTable strongToWeakObjectsMapTable];
216 233
 
217 234
         // Dynamically load custom bundled fonts.

+ 2
- 0
ios/sdk/src/RCTBridgeWrapper.h Wyświetl plik

@@ -34,4 +34,6 @@
34 34
 
35 35
 @property (nonatomic, readonly, strong)  RCTBridge *bridge;
36 36
 
37
+- (instancetype)initWithLaunchOptions:(NSDictionary *)launchOptions;
38
+
37 39
 @end

+ 4
- 2
ios/sdk/src/RCTBridgeWrapper.m Wyświetl plik

@@ -22,10 +22,12 @@
22 22
  */
23 23
 @implementation RCTBridgeWrapper
24 24
 
25
-- (instancetype)init {
25
+- (instancetype)initWithLaunchOptions:(NSDictionary *)launchOptions {
26 26
     self = [super init];
27 27
     if (self) {
28
-        _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:nil];
28
+        _bridge
29
+            = [[RCTBridge alloc] initWithDelegate:self
30
+                                    launchOptions:launchOptions];
29 31
     }
30 32
 
31 33
     return self;

Ładowanie…
Anuluj
Zapisz