File tree Expand file tree Collapse file tree 1 file changed +24
-12
lines changed
packages/url_launcher/ios/Classes Expand file tree Collapse file tree 1 file changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -92,18 +92,30 @@ - (BOOL)canLaunchURL:(NSString *)urlString {
9292- (void )launchURL : (NSString *)urlString result : (FlutterResult)result {
9393 NSURL *url = [NSURL URLWithString: urlString];
9494 UIApplication *application = [UIApplication sharedApplication ];
95- [application openURL: url
96- options: @{}
97- completionHandler: ^(BOOL success) {
98- if (success) {
99- result (nil );
100- } else {
101- result ([FlutterError
102- errorWithCode: @" Error"
103- message: [NSString stringWithFormat: @" Error while launching %@ " , url]
104- details: nil ]);
105- }
106- }];
95+ if ([application respondsToSelector: @selector (openURL:options:completionHandler: )]) {
96+ [application openURL: url
97+ options: @{}
98+ completionHandler: ^(BOOL success) {
99+ if (success) {
100+ result (nil );
101+ } else {
102+ result ([FlutterError
103+ errorWithCode: @" Error"
104+ message: [NSString stringWithFormat: @" Error while launching %@ " , url]
105+ details: nil ]);
106+ }
107+ }];
108+ } else {
109+ BOOL success = [application openURL: url];
110+ if (success) {
111+ result (nil );
112+ } else {
113+ result ([FlutterError
114+ errorWithCode: @" Error"
115+ message: [NSString stringWithFormat: @" Error while launching %@ " , url]
116+ details: nil ]);
117+ }
118+ }
107119}
108120
109121- (void )launchURLInVC : (NSString *)urlString result : (FlutterResult)result {
You can’t perform that action at this time.
0 commit comments