File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed
engine/src/flutter/shell/platform/darwin/ios/framework/Source Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -42,4 +42,42 @@ - (void)windowScene:(UIWindowScene*)windowScene
42
42
}
43
43
}
44
44
45
+ static NSDictionary <UIApplicationOpenURLOptionsKey, id >* ConvertOptions (
46
+ UISceneOpenURLOptions* options) {
47
+ if (@available (iOS 14.5 , *)) {
48
+ return @{
49
+ UIApplicationOpenURLOptionsSourceApplicationKey : options.sourceApplication
50
+ ? options.sourceApplication
51
+ : [NSNull null ],
52
+ UIApplicationOpenURLOptionsAnnotationKey : options.annotation ? options.annotation
53
+ : [NSNull null ],
54
+ UIApplicationOpenURLOptionsOpenInPlaceKey : @(options.openInPlace ),
55
+ UIApplicationOpenURLOptionsEventAttributionKey : options.eventAttribution
56
+ ? options.eventAttribution
57
+ : [NSNull null ],
58
+ };
59
+ } else {
60
+ return @{
61
+ UIApplicationOpenURLOptionsSourceApplicationKey : options.sourceApplication
62
+ ? options.sourceApplication
63
+ : [NSNull null ],
64
+ UIApplicationOpenURLOptionsAnnotationKey : options.annotation ? options.annotation
65
+ : [NSNull null ],
66
+ UIApplicationOpenURLOptionsOpenInPlaceKey : @(options.openInPlace ),
67
+ };
68
+ }
69
+ }
70
+
71
+ - (void )scene : (UIScene*)scene openURLContexts : (NSSet <UIOpenURLContext*>*)URLContexts {
72
+ id appDelegate = FlutterSharedApplication.application .delegate ;
73
+ if ([appDelegate respondsToSelector: @selector (lifeCycleDelegate )]) {
74
+ FlutterPluginAppLifeCycleDelegate* lifeCycleDelegate = [appDelegate lifeCycleDelegate ];
75
+ for (UIOpenURLContext* context in URLContexts) {
76
+ [lifeCycleDelegate application: FlutterSharedApplication.application
77
+ openURL: context.URL
78
+ options: ConvertOptions (context.options)];
79
+ };
80
+ }
81
+ }
82
+
45
83
@end
Original file line number Diff line number Diff line change @@ -42,4 +42,25 @@ - (void)testBridgeShortcut {
42
42
performActionForShortcutItem: [OCMArg any ]
43
43
completionHandler: [OCMArg any ]]);
44
44
}
45
+
46
+ - (void )testOpenURL {
47
+ id mockApplication = OCMClassMock ([UIApplication class ]);
48
+ OCMStub ([mockApplication sharedApplication ]).andReturn (mockApplication);
49
+ id mockAppDelegate = OCMClassMock ([FlutterAppDelegate class ]);
50
+ id mockLifecycleDelegate = OCMClassMock ([FlutterPluginAppLifeCycleDelegate class ]);
51
+ OCMStub ([mockApplication delegate ]).andReturn (mockAppDelegate);
52
+ OCMStub ([mockAppDelegate lifeCycleDelegate ]).andReturn (mockLifecycleDelegate);
53
+ id windowScene = OCMClassMock ([UIWindowScene class ]);
54
+ id urlContext = OCMClassMock ([UIOpenURLContext class ]);
55
+ NSURL * url = [NSURL URLWithString: @" http://example.com" ];
56
+ OCMStub ([urlContext URL ]).andReturn (url);
57
+
58
+ FlutterSceneDelegate* sceneDelegate = [[FlutterSceneDelegate alloc ] init ];
59
+ [sceneDelegate scene: windowScene openURLContexts: [NSSet setWithArray: @[ urlContext ]]];
60
+
61
+ OCMVerify ([(FlutterPluginAppLifeCycleDelegate*)mockLifecycleDelegate application: [OCMArg any ]
62
+ openURL: url
63
+ options: [OCMArg any ]]);
64
+ }
65
+
45
66
@end
You can’t perform that action at this time.
0 commit comments