Sfoglia il codice sorgente

[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.
j8
Saúl Ibarra Corretgé 8 anni fa
parent
commit
99b856233d

+ 5
- 4
ios/app/src/AppDelegate.m Vedi File

22
 
22
 
23
 -             (BOOL)application:(UIApplication *)application
23
 -             (BOOL)application:(UIApplication *)application
24
   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
24
   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
25
-    return YES;
25
+    return [JitsiMeetView application:application
26
+        didFinishLaunchingWithOptions:launchOptions];
26
 }
27
 }
27
 
28
 
28
 #pragma mark Linking delegate methods
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
     return [JitsiMeetView application:application
34
     return [JitsiMeetView application:application
34
                  continueUserActivity:userActivity
35
                  continueUserActivity:userActivity
35
                    restorationHandler:restorationHandler];
36
                    restorationHandler:restorationHandler];

+ 3
- 0
ios/sdk/src/JitsiMeetView.h Vedi File

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

+ 20
- 3
ios/sdk/src/JitsiMeetView.m Vedi File

35
     @try {
35
     @try {
36
         NSString *name
36
         NSString *name
37
             = [NSString stringWithFormat:@"%@: %@",
37
             = [NSString stringWithFormat:@"%@: %@",
38
-               RCTFatalExceptionName, error.localizedDescription];
38
+                        RCTFatalExceptionName,
39
+                        error.localizedDescription];
39
         NSString *message
40
         NSString *message
40
             = RCTFormatError(error.localizedDescription, jsStackTrace, 75);
41
             = RCTFormatError(error.localizedDescription, jsStackTrace, 75);
41
         [NSException raise:name format:@"%@", message];
42
         [NSException raise:name format:@"%@", message];
110
 
111
 
111
 static RCTBridgeWrapper *bridgeWrapper;
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
  * The {@code JitsiMeetView}s associated with their {@code ExternalAPI} scopes
122
  * The {@code JitsiMeetView}s associated with their {@code ExternalAPI} scopes
115
  * (i.e. unique identifiers within the process).
123
  * (i.e. unique identifiers within the process).
116
  */
124
  */
117
 static NSMapTable<NSString *, JitsiMeetView *> *views;
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
 #pragma mark Linking delegate helpers
135
 #pragma mark Linking delegate helpers
120
 // https://facebook.github.io/react-native/docs/linking.html
136
 // https://facebook.github.io/react-native/docs/linking.html
121
 
137
 
201
 /**
217
 /**
202
  * Internal initialization:
218
  * Internal initialization:
203
  *
219
  *
204
- * - sets the backgroudn color
220
+ * - sets the background color
205
  * - creates the React bridge
221
  * - creates the React bridge
206
  * - loads the necessary custom fonts
222
  * - loads the necessary custom fonts
207
  * - registers a custom fatal error error handler for React
223
  * - registers a custom fatal error error handler for React
211
 
227
 
212
     dispatch_once(&dispatchOncePredicate, ^{
228
     dispatch_once(&dispatchOncePredicate, ^{
213
         // Initialize the static state of JitsiMeetView.
229
         // Initialize the static state of JitsiMeetView.
214
-        bridgeWrapper = [[RCTBridgeWrapper alloc] init];
230
+        bridgeWrapper
231
+            = [[RCTBridgeWrapper alloc] initWithLaunchOptions:_launchOptions];
215
         views = [NSMapTable strongToWeakObjectsMapTable];
232
         views = [NSMapTable strongToWeakObjectsMapTable];
216
 
233
 
217
         // Dynamically load custom bundled fonts.
234
         // Dynamically load custom bundled fonts.

+ 2
- 0
ios/sdk/src/RCTBridgeWrapper.h Vedi File

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

+ 4
- 2
ios/sdk/src/RCTBridgeWrapper.m Vedi File

22
  */
22
  */
23
 @implementation RCTBridgeWrapper
23
 @implementation RCTBridgeWrapper
24
 
24
 
25
-- (instancetype)init {
25
+- (instancetype)initWithLaunchOptions:(NSDictionary *)launchOptions {
26
     self = [super init];
26
     self = [super init];
27
     if (self) {
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
     return self;
33
     return self;

Loading…
Annulla
Salva