|
4 | 4 |
|
5 | 5 | #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h" |
6 | 6 |
|
7 | | -#include "flutter/fml/logging.h" |
| 7 | +#import "flutter/fml/logging.h" |
8 | 8 | #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h" |
9 | 9 | #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" |
10 | 10 | #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate_internal.h" |
| 11 | +#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" |
11 | 12 |
|
12 | 13 | static NSString* kUIBackgroundMode = @"UIBackgroundModes"; |
13 | 14 | static NSString* kRemoteNotificationCapabitiliy = @"remote-notification"; |
@@ -124,7 +125,28 @@ - (void)userNotificationCenter:(UNUserNotificationCenter*)center |
124 | 125 | - (BOOL)application:(UIApplication*)application |
125 | 126 | openURL:(NSURL*)url |
126 | 127 | options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options { |
127 | | - return [_lifeCycleDelegate application:application openURL:url options:options]; |
| 128 | + if ([_lifeCycleDelegate application:application openURL:url options:options]) { |
| 129 | + return YES; |
| 130 | + } else { |
| 131 | + UIViewController* rootViewController = _window.rootViewController; |
| 132 | + if ([rootViewController isKindOfClass:[FlutterViewController class]]) { |
| 133 | + FlutterViewController* flutterViewController = (FlutterViewController*)rootViewController; |
| 134 | + [flutterViewController.engine |
| 135 | + waitForFirstFrame:3.0 |
| 136 | + callback:^(BOOL didTimeout) { |
| 137 | + if (didTimeout) { |
| 138 | + FML_LOG(ERROR) |
| 139 | + << "Timeout waiting for the first frame when launching an URL."; |
| 140 | + } else { |
| 141 | + [flutterViewController.engine.navigationChannel invokeMethod:@"pushRoute" |
| 142 | + arguments:url.path]; |
| 143 | + } |
| 144 | + }]; |
| 145 | + } else { |
| 146 | + FML_LOG(ERROR) << "Attempting to open an URL without a Flutter RootViewController."; |
| 147 | + } |
| 148 | + return YES; |
| 149 | + } |
128 | 150 | } |
129 | 151 |
|
130 | 152 | - (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url { |
|
0 commit comments