|
39 | 39 |
|
40 | 40 | #import <Batch/BAEventDispatcherCenter.h>
|
41 | 41 | #import <Batch/BAInjection.h>
|
| 42 | +#import <Batch/BAApplicationLifecycle.h> |
42 | 43 |
|
43 | 44 | #define LOGGER_DOMAIN @"Core"
|
44 | 45 |
|
@@ -439,21 +440,43 @@ - (BOOL)openUniversalLinkIfPossible:(NSURL *)URL {
|
439 | 440 | [BALogger debugForDomain:LOGGER_DOMAIN
|
440 | 441 | message:@"Transferring universal link '%@' to UIApplication", URL.absoluteString];
|
441 | 442 |
|
442 |
| - // Transferring url to application:continueUserActivity:restorationHandler |
| 443 | + // Transferring url to application:continueUserActivity:restorationHandler or scene:continueUserActivity: |
443 | 444 | NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:NSUserActivityTypeBrowsingWeb];
|
444 | 445 | userActivity.webpageURL = URL;
|
| 446 | + |
| 447 | + Boolean errorAlreadyLogged = false; |
| 448 | + |
| 449 | + if (@available(iOS 13.0, *)) { |
| 450 | + if ([BAApplicationLifecycle applicationUsesUIScene]) { |
| 451 | + UIScene* scene = [[UIApplication sharedApplication].connectedScenes allObjects].firstObject; |
| 452 | + id<UISceneDelegate> sceneDelegate = [scene delegate]; |
| 453 | + if ([sceneDelegate respondsToSelector:@selector(scene:continueUserActivity:)]) { |
| 454 | + [sceneDelegate scene:scene continueUserActivity:userActivity]; |
| 455 | + return YES; |
| 456 | + } else { |
| 457 | + [BALogger debugForDomain:LOGGER_DOMAIN |
| 458 | + message:@"It looks like scene:continueUserActivity: is not " |
| 459 | + @"implemented, did you correctly add it to your SceneDelegate?"]; |
| 460 | + errorAlreadyLogged = true; |
| 461 | + } |
| 462 | + } |
| 463 | + } |
| 464 | + |
445 | 465 | id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
|
446 | 466 | if ([appDelegate respondsToSelector:@selector(application:continueUserActivity:restorationHandler:)]) {
|
447 | 467 | [appDelegate application:[UIApplication sharedApplication]
|
448 | 468 | continueUserActivity:userActivity
|
449 | 469 | restorationHandler:nil];
|
450 | 470 | return YES;
|
451 |
| - } else { |
| 471 | + } |
| 472 | + if (!errorAlreadyLogged) { |
452 | 473 | [BALogger debugForDomain:LOGGER_DOMAIN
|
453 | 474 | message:@"It looks like application:continueUserActivity:restorationHandler is not "
|
454 |
| - @"implemented, did you correctly add it to your AppDelegate ?"]; |
455 |
| - return NO; |
| 475 | + @"implemented, did you correctly add it to your AppDelegate?"]; |
456 | 476 | }
|
| 477 | + |
| 478 | + return NO; |
| 479 | + |
457 | 480 | }
|
458 | 481 |
|
459 | 482 | // Check for potential incompatibilities/misconfigurations, and warn the developer
|
|
0 commit comments