From d7b5dbb23542ba3be1e9ce20b88d931212c0ac26 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Mon, 24 Apr 2017 16:32:43 +0200 Subject: [PATCH 01/11] add canLaunch Android --- .../url_launcher/UrlLauncherPlugin.java | 84 ++++++++++++------- packages/url-launcher/example/lib/main.dart | 55 +++++++++--- packages/url-launcher/lib/url_launcher.dart | 15 +++- 3 files changed, 114 insertions(+), 40 deletions(-) diff --git a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java index c20f7e75c3d4..d018c05b2a56 100644 --- a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java +++ b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java @@ -1,7 +1,17 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + package io.flutter.plugins.url_launcher; +import android.content.ComponentName; import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.net.Uri; +import android.provider.Settings; + +import java.util.List; import io.flutter.app.FlutterActivity; import io.flutter.plugin.common.MethodChannel; @@ -13,34 +23,52 @@ * UrlLauncherPlugin */ public class UrlLauncherPlugin implements MethodCallHandler { - private FlutterActivity activity; - - public static UrlLauncherPlugin register(FlutterActivity activity) { - return new UrlLauncherPlugin(activity); - } - - private UrlLauncherPlugin(FlutterActivity activity) { - this.activity = activity; - new MethodChannel( - activity.getFlutterView(), "plugins.flutter.io/URLLauncher").setMethodCallHandler(this); - } - - @Override - public void onMethodCall(MethodCall call, Result result) { - if (call.method.equals("UrlLauncher.launch")) { - launchURL((String) call.arguments); - result.success(null); - } else { - result.notImplemented(); + private FlutterActivity activity; + + public static UrlLauncherPlugin register(FlutterActivity activity) { + return new UrlLauncherPlugin(activity); + } + + private UrlLauncherPlugin(FlutterActivity activity) { + this.activity = activity; + new MethodChannel( + activity.getFlutterView(), "plugins.flutter.io/URLLauncher").setMethodCallHandler(this); + } + + @Override + public void onMethodCall(MethodCall call, Result result) { + if (call.method.equals("UrlLauncher.canLaunch")) { + //todo upgrade flutter + canLaunch((String) call.arguments, result); + } else if (call.method.equals("UrlLauncher.launch")) { + launchURL((String) call.arguments, result); + } else { + result.notImplemented(); + } + } + + private void launchURL(String url, Result result) { + try { + Intent launchIntent = new Intent(Intent.ACTION_VIEW); + launchIntent.setData(Uri.parse(url)); + activity.startActivity(launchIntent); + result.success(null); + } catch (java.lang.Exception exception) { + result.error("ERROR", exception.getMessage(), null); + } } - } - private void launchURL(String url) { - try { - Intent launchIntent = new Intent(Intent.ACTION_VIEW); - launchIntent.setData(Uri.parse(url)); - activity.startActivity(launchIntent); - } catch (java.lang.Exception exception) { - // Ignore parsing or ActivityNotFound errors + + private void canLaunch(String url, Result result) { + Intent launchIntent = new Intent(Intent.ACTION_VIEW); + launchIntent.setData(Uri.parse(url)); + ComponentName componentName = launchIntent.resolveActivity(activity.getPackageManager()); + if (componentName == null || + "{com.android.fallback/com.android.fallback.Fallback}". + equals(componentName.toShortString())) { + result.success(false); + } + + result.success(true); + } - } } diff --git a/packages/url-launcher/example/lib/main.dart b/packages/url-launcher/example/lib/main.dart index 86018261b4ac..4c8b67a2004b 100644 --- a/packages/url-launcher/example/lib/main.dart +++ b/packages/url-launcher/example/lib/main.dart @@ -1,6 +1,13 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; + void main() { runApp(new MyApp()); } @@ -27,8 +34,28 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { + Future _launched; + void _launchUrl() { - launch('https://flutter.io'); + setState(() { + _launched = _launch('https://flutter.io'); + }); + } + + Future _launch(String url) async { + if (await canLaunch(url)) { + await launch(url); + } else { + throw "Cannot launch $url"; + } + } + + Widget _launchStatus(BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.hasError) { + return new Text('Error: ${snapshot.error}'); + } else { + return const Text(''); + } } @override @@ -38,17 +65,23 @@ class _MyHomePageState extends State { title: new Text(widget.title), ), body: new Center( - child: new Row( - mainAxisSize: MainAxisSize.min, - children: [ - new Padding( - padding: new EdgeInsets.all(16.0), - child: new Text("https://flutter.io"), - ), - new RaisedButton( - onPressed: _launchUrl, - child: new Text("Go"), + child: new Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + new Row( + mainAxisSize: MainAxisSize.min, + children: [ + new Padding( + padding: new EdgeInsets.all(16.0), + child: new Text("https://flutter.io"), + ), + new RaisedButton( + onPressed: _launchUrl, + child: new Text("Go"), + ), + ], ), + new FutureBuilder(future: _launched, builder: _launchStatus), ], ), ), diff --git a/packages/url-launcher/lib/url_launcher.dart b/packages/url-launcher/lib/url_launcher.dart index cef7d7a82a2d..2847c01020e2 100644 --- a/packages/url-launcher/lib/url_launcher.dart +++ b/packages/url-launcher/lib/url_launcher.dart @@ -1,12 +1,25 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import 'dart:async'; import 'package:flutter/services.dart'; +const _channel = const MethodChannel('plugins.flutter.io/URLLauncher'); + /// Parse the specified URL string and delegate handling of the same to the /// underlying platform. Future launch(String urlString) { - return const MethodChannel('plugins.flutter.io/URLLauncher').invokeMethod( + return _channel.invokeMethod( 'UrlLauncher.launch', urlString, ); } + +Future canLaunch(String urlString) { + return _channel.invokeMethod( + 'UrlLauncher.canLaunch', + urlString, + ); +} From 7c3ed278dc4dc6a80b355cbbee535a250a5e16f9 Mon Sep 17 00:00:00 2001 From: Sarah Winther Zakarias Date: Thu, 27 Apr 2017 13:39:33 +0200 Subject: [PATCH 02/11] add ios canLaunch --- .../ios/Pods/Pods.xcodeproj/project.pbxproj | 102 +++++++++--------- .../Pods-Runner/Pods-Runner-frameworks.sh | 4 +- .../Pods-Runner/Pods-Runner.debug.xcconfig | 2 +- .../Pods-Runner/Pods-Runner.release.xcconfig | 2 +- .../ios/Classes/UrlLauncherPlugin.m | 44 ++++++-- 5 files changed, 92 insertions(+), 62 deletions(-) diff --git a/packages/url-launcher/example/ios/Pods/Pods.xcodeproj/project.pbxproj b/packages/url-launcher/example/ios/Pods/Pods.xcodeproj/project.pbxproj index d3b2f6e47881..b703a6beec2d 100644 --- a/packages/url-launcher/example/ios/Pods/Pods.xcodeproj/project.pbxproj +++ b/packages/url-launcher/example/ios/Pods/Pods.xcodeproj/project.pbxproj @@ -7,14 +7,14 @@ objects = { /* Begin PBXBuildFile section */ - 0E483423E9DCAEA9851A77F4678074A9 /* UrlLauncherPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C18D72EA8BAB1FC3C0FCE584E0A310E /* UrlLauncherPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 0E483423E9DCAEA9851A77F4678074A9 /* UrlLauncherPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = DBB19A6417A00E2709A4CC67BC499435 /* UrlLauncherPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B0ACC20E310CA80EFB60BF34C9B4184 /* Pods-Runner-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E631AC9676BE84AEB52F7D6520E4684 /* Pods-Runner-dummy.m */; }; 4415323DEF18C14449AA182F7811169E /* Pods-Runner-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 800A16960E73EBAF012C139238277358 /* Pods-Runner-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 568F29DDF606A6C38F8DF8EED181E02A /* url_launcher-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = B241FCE379E0E69CF112BE404067F65C /* url_launcher-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 568F29DDF606A6C38F8DF8EED181E02A /* url_launcher-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = D33EE0AFDF865FC57DE4AFE8D4A1FE2D /* url_launcher-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; 74DD29F300E0CBE5C7ECCD118B18AFF1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBB3DE36805AF21409EC968A9691732F /* Foundation.framework */; }; 7C942C0895A8904C17777BD7F7929526 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBB3DE36805AF21409EC968A9691732F /* Foundation.framework */; }; - B675652788D552B0B818758E03B07B16 /* UrlLauncherPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D3BACBA6F7E36892A1B6492CB55DEB5 /* UrlLauncherPlugin.m */; }; - EE31ED9F7764675F7D27B13E08EE4351 /* url_launcher-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = EC54CA739E4C29E530C11E341B837700 /* url_launcher-dummy.m */; }; + B675652788D552B0B818758E03B07B16 /* UrlLauncherPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A5EC4C1C7345C1568EA4391116B5FA5 /* UrlLauncherPlugin.m */; }; + EE31ED9F7764675F7D27B13E08EE4351 /* url_launcher-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 93FBA44B61BC2932F585020591D983DE /* url_launcher-dummy.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -29,28 +29,28 @@ /* Begin PBXFileReference section */ 09472E02B60DD42496A3E3B59C6F14B6 /* url_launcher.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = url_launcher.framework; path = url_launcher.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 0D3BACBA6F7E36892A1B6492CB55DEB5 /* UrlLauncherPlugin.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = UrlLauncherPlugin.m; sourceTree = ""; }; 1230911B0B1C1A5E00676A90606DE300 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1E631AC9676BE84AEB52F7D6520E4684 /* Pods-Runner-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Runner-dummy.m"; sourceTree = ""; }; - 34E1DEDD52719A2742E34C53D93CB0D9 /* url_launcher-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "url_launcher-prefix.pch"; sourceTree = ""; }; + 31988D6AAEEC615DF7F8C1AA0A95CC28 /* url_launcher.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = url_launcher.modulemap; sourceTree = ""; }; + 3A5EC4C1C7345C1568EA4391116B5FA5 /* UrlLauncherPlugin.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = UrlLauncherPlugin.m; sourceTree = ""; }; 48E25B5D7653FD9F13A9662BB6AF2D86 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_Runner.framework; path = "Pods-Runner.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; - 4C18D72EA8BAB1FC3C0FCE584E0A310E /* UrlLauncherPlugin.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = UrlLauncherPlugin.h; sourceTree = ""; }; - 4F8BCA982F22D010C0F3751AAC7E3C1B /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4FDED4BA7D4F5DF30B2103FF868343B2 /* url_launcher.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = url_launcher.xcconfig; sourceTree = ""; }; + 537A6898C89F37EC7BE5BF570CDE5529 /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Flutter.framework; sourceTree = ""; }; 5EB571A3ABC7BF67A4642C216D6F0E21 /* Pods-Runner-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Runner-resources.sh"; sourceTree = ""; }; 60BA499A645871628CFA2E5806E78269 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Runner.release.xcconfig"; sourceTree = ""; }; 63BC99522783D0218755FDE8464650E4 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - 6C259E7AAD6CFE65A1929C7AE2F2149C /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Flutter.framework; sourceTree = ""; }; - 7FE36E7B286DF735A45138EED907BD05 /* url_launcher.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = url_launcher.modulemap; sourceTree = ""; }; 800A16960E73EBAF012C139238277358 /* Pods-Runner-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Runner-umbrella.h"; sourceTree = ""; }; 820303DDBFB04D47450E66B28FF32086 /* Pods-Runner-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Runner-acknowledgements.plist"; sourceTree = ""; }; + 8629EEB906A7D06D81A6ED5F5D9991FF /* url_launcher-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "url_launcher-prefix.pch"; sourceTree = ""; }; 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - B241FCE379E0E69CF112BE404067F65C /* url_launcher-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "url_launcher-umbrella.h"; sourceTree = ""; }; + 93FBA44B61BC2932F585020591D983DE /* url_launcher-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "url_launcher-dummy.m"; sourceTree = ""; }; B8331DA3DF79C3AB28033920E45C4B46 /* Pods-Runner-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Runner-frameworks.sh"; sourceTree = ""; }; + B8CE98FF8B1978EDB8B54B7B3FE5E630 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; BE191574A51A7A7D07FEEACB1323F4E5 /* Pods-Runner.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = "Pods-Runner.modulemap"; sourceTree = ""; }; CA0501A66E945611274FD9BED1573FA5 /* Pods-Runner-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Runner-acknowledgements.markdown"; sourceTree = ""; }; CBB3DE36805AF21409EC968A9691732F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - EC54CA739E4C29E530C11E341B837700 /* url_launcher-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "url_launcher-dummy.m"; sourceTree = ""; }; - FF074A713E045420CE534C44F0714398 /* url_launcher.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = url_launcher.xcconfig; sourceTree = ""; }; + D33EE0AFDF865FC57DE4AFE8D4A1FE2D /* url_launcher-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "url_launcher-umbrella.h"; sourceTree = ""; }; + DBB19A6417A00E2709A4CC67BC499435 /* UrlLauncherPlugin.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = UrlLauncherPlugin.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -73,70 +73,80 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 2CA9FE3F5F1970ED10865F8F8F801B37 /* Development Pods */ = { + 18070631AF21DF6AF05EF8800C08C3B4 /* Frameworks */ = { isa = PBXGroup; children = ( - 9EA7DAF2ABC963E27C71D95155AA6383 /* Flutter */, - C9845581E162B3675B72C928ECAD12E2 /* url_launcher */, + 537A6898C89F37EC7BE5BF570CDE5529 /* Flutter.framework */, ); - name = "Development Pods"; + name = Frameworks; sourceTree = ""; }; - 2CBBD2BBAF933B29A5485E559E24299A /* Classes */ = { + 7531C8F8DE19F1AA3C8A7AC97A91DC29 /* iOS */ = { isa = PBXGroup; children = ( - 4C18D72EA8BAB1FC3C0FCE584E0A310E /* UrlLauncherPlugin.h */, - 0D3BACBA6F7E36892A1B6492CB55DEB5 /* UrlLauncherPlugin.m */, + CBB3DE36805AF21409EC968A9691732F /* Foundation.framework */, ); - name = Classes; - path = Classes; + name = iOS; sourceTree = ""; }; - 7531C8F8DE19F1AA3C8A7AC97A91DC29 /* iOS */ = { + 7D45BA6CBE8EEF5E46C6761CCDF60B06 /* Development Pods */ = { isa = PBXGroup; children = ( - CBB3DE36805AF21409EC968A9691732F /* Foundation.framework */, + A8AD025A0715AA1BCA1BE8CAC29A029B /* Flutter */, + 8A8F602384D136C1024D2774B770BC21 /* url_launcher */, ); - name = iOS; + name = "Development Pods"; sourceTree = ""; }; 7DB346D0F39D3F0E887471402A8071AB = { isa = PBXGroup; children = ( 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, - 2CA9FE3F5F1970ED10865F8F8F801B37 /* Development Pods */, + 7D45BA6CBE8EEF5E46C6761CCDF60B06 /* Development Pods */, BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */, F20E12BEB87796FA91406DA2EEDF8F75 /* Products */, B88D6092221BFC46BA797811AC7C0DEC /* Targets Support Files */, ); sourceTree = ""; }; - 99ACA14533349144112BBA3BBFE4912C /* Frameworks */ = { + 8A8F602384D136C1024D2774B770BC21 /* url_launcher */ = { isa = PBXGroup; children = ( - 6C259E7AAD6CFE65A1929C7AE2F2149C /* Flutter.framework */, + 8D07D777E9B2A0CBE17035732DB3A141 /* Classes */, + AF12D087686A3EFD85941828E0BCC355 /* Support Files */, ); - name = Frameworks; + name = url_launcher; + path = "/Users/zarah/plugins/packages/url-launcher/ios"; + sourceTree = ""; + }; + 8D07D777E9B2A0CBE17035732DB3A141 /* Classes */ = { + isa = PBXGroup; + children = ( + DBB19A6417A00E2709A4CC67BC499435 /* UrlLauncherPlugin.h */, + 3A5EC4C1C7345C1568EA4391116B5FA5 /* UrlLauncherPlugin.m */, + ); + name = Classes; + path = Classes; sourceTree = ""; }; - 9EA7DAF2ABC963E27C71D95155AA6383 /* Flutter */ = { + A8AD025A0715AA1BCA1BE8CAC29A029B /* Flutter */ = { isa = PBXGroup; children = ( - 99ACA14533349144112BBA3BBFE4912C /* Frameworks */, + 18070631AF21DF6AF05EF8800C08C3B4 /* Frameworks */, ); name = Flutter; - path = "/Users/zarah/flutter/bin/cache/artifacts/engine/ios-release"; + path = /Users/zarah/flutter/bin/cache/artifacts/engine/ios; sourceTree = ""; }; - ACF591A9AAFFE9A5DEEAD4CD4EC5352D /* Support Files */ = { + AF12D087686A3EFD85941828E0BCC355 /* Support Files */ = { isa = PBXGroup; children = ( - 4F8BCA982F22D010C0F3751AAC7E3C1B /* Info.plist */, - 7FE36E7B286DF735A45138EED907BD05 /* url_launcher.modulemap */, - FF074A713E045420CE534C44F0714398 /* url_launcher.xcconfig */, - EC54CA739E4C29E530C11E341B837700 /* url_launcher-dummy.m */, - 34E1DEDD52719A2742E34C53D93CB0D9 /* url_launcher-prefix.pch */, - B241FCE379E0E69CF112BE404067F65C /* url_launcher-umbrella.h */, + B8CE98FF8B1978EDB8B54B7B3FE5E630 /* Info.plist */, + 31988D6AAEEC615DF7F8C1AA0A95CC28 /* url_launcher.modulemap */, + 4FDED4BA7D4F5DF30B2103FF868343B2 /* url_launcher.xcconfig */, + 93FBA44B61BC2932F585020591D983DE /* url_launcher-dummy.m */, + 8629EEB906A7D06D81A6ED5F5D9991FF /* url_launcher-prefix.pch */, + D33EE0AFDF865FC57DE4AFE8D4A1FE2D /* url_launcher-umbrella.h */, ); name = "Support Files"; path = "../example/ios/Pods/Target Support Files/url_launcher"; @@ -158,16 +168,6 @@ name = Frameworks; sourceTree = ""; }; - C9845581E162B3675B72C928ECAD12E2 /* url_launcher */ = { - isa = PBXGroup; - children = ( - 2CBBD2BBAF933B29A5485E559E24299A /* Classes */, - ACF591A9AAFFE9A5DEEAD4CD4EC5352D /* Support Files */, - ); - name = url_launcher; - path = "/Users/zarah/plugins/packages/url-launcher/ios"; - sourceTree = ""; - }; ECC1486D1F14EC5BA692C079D9D06161 /* Pods-Runner */ = { isa = PBXGroup; children = ( @@ -433,7 +433,7 @@ }; 66B9050C99E4D2D621D4C7E6F1944502 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF074A713E045420CE534C44F0714398 /* url_launcher.xcconfig */; + baseConfigurationReference = 4FDED4BA7D4F5DF30B2103FF868343B2 /* url_launcher.xcconfig */; buildSettings = { ARCHS = arm64; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; @@ -503,7 +503,7 @@ }; D5E30FCB1F1B03C78FBACDDD90DBAD54 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FF074A713E045420CE534C44F0714398 /* url_launcher.xcconfig */; + baseConfigurationReference = 4FDED4BA7D4F5DF30B2103FF868343B2 /* url_launcher.xcconfig */; buildSettings = { ARCHS = arm64; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; diff --git a/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh b/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh index ca7c17060c95..84e33cb7b6e8 100755 --- a/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh +++ b/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh @@ -89,11 +89,11 @@ strip_invalid_archs() { if [[ "$CONFIGURATION" == "Debug" ]]; then - install_framework "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios-release/Flutter.framework" + install_framework "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios/Flutter.framework" install_framework "$BUILT_PRODUCTS_DIR/url_launcher/url_launcher.framework" fi if [[ "$CONFIGURATION" == "Release" ]]; then - install_framework "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios-release/Flutter.framework" + install_framework "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios/Flutter.framework" install_framework "$BUILT_PRODUCTS_DIR/url_launcher/url_launcher.framework" fi if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then diff --git a/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig b/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig index 81ffb4884db2..283f6a71cf3a 100644 --- a/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig +++ b/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig @@ -1,4 +1,4 @@ -FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/url_launcher" "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios-release" +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/url_launcher" "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Flutter" LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' diff --git a/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig b/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig index 81ffb4884db2..283f6a71cf3a 100644 --- a/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig +++ b/packages/url-launcher/example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig @@ -1,4 +1,4 @@ -FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/url_launcher" "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios-release" +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/url_launcher" "${PODS_ROOT}/../../../../../../flutter/bin/cache/artifacts/engine/ios" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Flutter" LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' diff --git a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m index ea4d43a10d46..85eea178d2aa 100644 --- a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m +++ b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m @@ -3,7 +3,7 @@ @implementation UrlLauncherPlugin { } -- (instancetype)initWithController:(FlutterViewController *)controller { +- (instancetype)initWithController:(FlutterViewController*)controller { self = [super init]; if (self) { FlutterMethodChannel* channel = [FlutterMethodChannel @@ -11,20 +11,50 @@ - (instancetype)initWithController:(FlutterViewController *)controller { binaryMessenger:controller]; [channel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) { - if ([@"UrlLauncher.launch" isEqualToString:call.method]) { - [self launchURL:call.arguments]; - result(nil); + NSString* url = call.arguments; + if ([@"UrlLauncher.canLaunch" isEqualToString:call.method]) { + BOOL can = ([self canLaunchURL:url]); + result(@(can)); + } else if ([@"UrlLauncher.launch" isEqualToString:call.method]) { + [self launchURL:url result:result]; + } else { + result(FlutterMethodNotImplemented); } }]; } + return self; } -- (NSDictionary*)launchURL:(NSString*)urlString { +- (BOOL)canLaunchURL:(NSString*)urlString { + NSURL* url = [NSURL URLWithString:urlString]; + UIApplication* application = [UIApplication sharedApplication]; + return [application canOpenURL:url]; +} + +- (void)launchURL:(NSString*)urlString result:(FlutterResult)result { NSURL* url = [NSURL URLWithString:urlString]; UIApplication* application = [UIApplication sharedApplication]; - bool success = [application canOpenURL:url] && [application openURL:url]; - return @{@"success": @(success) }; + if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) { + // iOS 10 and above + [application openURL:url options:@{} completionHandler: ^(BOOL success) { + [self sendResult:success result:result url:url]; + }]; + } else { + [self sendResult:[application openURL:url] result:result url:url]; + } +} + +- (void)sendResult:(BOOL)success result:(FlutterResult)result url:(NSURL*)url { + if (success) { + result(nil); + } else { + result([FlutterError errorWithCode:@"Error" + message:[NSString stringWithFormat:@"Error while launching %@", url] + details:nil]); + + } + } @end From 2b3b91ec7682fdedb366b8552cd118bc64749b6f Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 27 Apr 2017 13:42:10 +0200 Subject: [PATCH 03/11] fix --- .../plugins/url_launcher/UrlLauncherPlugin.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java index d018c05b2a56..5bdf5e905f17 100644 --- a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java +++ b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java @@ -6,12 +6,7 @@ import android.content.ComponentName; import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.net.Uri; -import android.provider.Settings; - -import java.util.List; import io.flutter.app.FlutterActivity; import io.flutter.plugin.common.MethodChannel; @@ -67,8 +62,9 @@ private void canLaunch(String url, Result result) { equals(componentName.toShortString())) { result.success(false); } - - result.success(true); + else { + result.success(true); + } } } From 6c6e71d3950300d3ac42e52917c07456d255be62 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 27 Apr 2017 14:25:57 +0200 Subject: [PATCH 04/11] android --- .../io/flutter/plugins/url_launcher/UrlLauncherPlugin.java | 7 +++---- packages/url-launcher/example/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java index 5bdf5e905f17..3a3887f5f954 100644 --- a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java +++ b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java @@ -32,11 +32,11 @@ private UrlLauncherPlugin(FlutterActivity activity) { @Override public void onMethodCall(MethodCall call, Result result) { + String url = call.arguments(); if (call.method.equals("UrlLauncher.canLaunch")) { - //todo upgrade flutter - canLaunch((String) call.arguments, result); + canLaunch(url, result); } else if (call.method.equals("UrlLauncher.launch")) { - launchURL((String) call.arguments, result); + launchURL(url, result); } else { result.notImplemented(); } @@ -65,6 +65,5 @@ private void canLaunch(String url, Result result) { else { result.success(true); } - } } diff --git a/packages/url-launcher/example/android/build.gradle b/packages/url-launcher/example/android/build.gradle index ee5325df808c..baaf22d01b40 100644 --- a/packages/url-launcher/example/android/build.gradle +++ b/packages/url-launcher/example/android/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.1' } } From 96c1963b58eed617e05cba0789b75974cba4da0c Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 27 Apr 2017 14:28:45 +0200 Subject: [PATCH 05/11] newline --- packages/url-launcher/example/lib/main.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/url-launcher/example/lib/main.dart b/packages/url-launcher/example/lib/main.dart index 4c8b67a2004b..25153a59d334 100644 --- a/packages/url-launcher/example/lib/main.dart +++ b/packages/url-launcher/example/lib/main.dart @@ -7,7 +7,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; - void main() { runApp(new MyApp()); } From 44786cc50eb317df52cb48faf3d2056c0c99667a Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 27 Apr 2017 14:30:53 +0200 Subject: [PATCH 06/11] error message --- packages/url-launcher/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/url-launcher/example/lib/main.dart b/packages/url-launcher/example/lib/main.dart index 25153a59d334..9e34ea45d83b 100644 --- a/packages/url-launcher/example/lib/main.dart +++ b/packages/url-launcher/example/lib/main.dart @@ -45,7 +45,7 @@ class _MyHomePageState extends State { if (await canLaunch(url)) { await launch(url); } else { - throw "Cannot launch $url"; + throw "Could not launch $url"; } } From 6c1e6331bb1c7460970398fd6c843aea0701a558 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 27 Apr 2017 14:44:23 +0200 Subject: [PATCH 07/11] update pubspec and changelog --- packages/url-launcher/CHANGELOG.md | 3 +++ packages/url-launcher/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/url-launcher/CHANGELOG.md b/packages/url-launcher/CHANGELOG.md index 2cb5ffed5340..4c98b259cf8f 100644 --- a/packages/url-launcher/CHANGELOG.md +++ b/packages/url-launcher/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.3.0] - 2017-04-27 + +* Add `canLaunch` method. ## [0.2.0] - 2017-04-24 diff --git a/packages/url-launcher/pubspec.yaml b/packages/url-launcher/pubspec.yaml index 083cd90ac3b3..92e2c458e01a 100644 --- a/packages/url-launcher/pubspec.yaml +++ b/packages/url-launcher/pubspec.yaml @@ -1,6 +1,6 @@ name: url_launcher -version: 0.2.0 +version: 0.3.0 description: Flutter plugin for launching a URL author: Flutter Team homepage: https://github.com/flutter/plugins From 4354c1a79ed4fc899dc2cf1eb01d9564d5b1a137 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 27 Apr 2017 15:12:27 +0200 Subject: [PATCH 08/11] formatting --- .../io/flutter/plugins/url_launcher/UrlLauncherPlugin.java | 3 +-- packages/url-launcher/ios/Classes/UrlLauncherPlugin.m | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java index 3a3887f5f954..4cee74299fb4 100644 --- a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java +++ b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java @@ -61,8 +61,7 @@ private void canLaunch(String url, Result result) { "{com.android.fallback/com.android.fallback.Fallback}". equals(componentName.toShortString())) { result.success(false); - } - else { + } else { result.success(true); } } diff --git a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m index 85eea178d2aa..53622fabdb3c 100644 --- a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m +++ b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m @@ -13,8 +13,7 @@ - (instancetype)initWithController:(FlutterViewController*)controller { FlutterResult result) { NSString* url = call.arguments; if ([@"UrlLauncher.canLaunch" isEqualToString:call.method]) { - BOOL can = ([self canLaunchURL:url]); - result(@(can)); + result(@([self canLaunchURL:url])); } else if ([@"UrlLauncher.launch" isEqualToString:call.method]) { [self launchURL:url result:result]; } else { @@ -22,7 +21,6 @@ - (instancetype)initWithController:(FlutterViewController*)controller { } }]; } - return self; } From 16634fc9de3df5d143f8693e0f8aae4863bc0d4a Mon Sep 17 00:00:00 2001 From: Sarah Winther Zakarias Date: Thu, 27 Apr 2017 21:02:23 +0200 Subject: [PATCH 09/11] comments --- .../url_launcher/UrlLauncherPlugin.java | 28 ++++++++----------- .../url-launcher/example/android/build.gradle | 2 +- packages/url-launcher/example/lib/main.dart | 6 ++-- .../ios/Classes/UrlLauncherPlugin.m | 6 ++-- packages/url-launcher/lib/url_launcher.dart | 6 ++-- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java index 4cee74299fb4..b2a5fba28736 100644 --- a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java +++ b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java @@ -27,15 +27,15 @@ public static UrlLauncherPlugin register(FlutterActivity activity) { private UrlLauncherPlugin(FlutterActivity activity) { this.activity = activity; new MethodChannel( - activity.getFlutterView(), "plugins.flutter.io/URLLauncher").setMethodCallHandler(this); + activity.getFlutterView(), "plugins.flutter.io/url_launcher").setMethodCallHandler(this); } @Override public void onMethodCall(MethodCall call, Result result) { String url = call.arguments(); - if (call.method.equals("UrlLauncher.canLaunch")) { + if (call.method.equals("canLaunch")) { canLaunch(url, result); - } else if (call.method.equals("UrlLauncher.launch")) { + } else if (call.method.equals("launch")) { launchURL(url, result); } else { result.notImplemented(); @@ -43,26 +43,20 @@ public void onMethodCall(MethodCall call, Result result) { } private void launchURL(String url, Result result) { - try { - Intent launchIntent = new Intent(Intent.ACTION_VIEW); - launchIntent.setData(Uri.parse(url)); - activity.startActivity(launchIntent); - result.success(null); - } catch (java.lang.Exception exception) { - result.error("ERROR", exception.getMessage(), null); - } + Intent launchIntent = new Intent(Intent.ACTION_VIEW); + launchIntent.setData(Uri.parse(url)); + activity.startActivity(launchIntent); + result.success(null); } private void canLaunch(String url, Result result) { Intent launchIntent = new Intent(Intent.ACTION_VIEW); launchIntent.setData(Uri.parse(url)); ComponentName componentName = launchIntent.resolveActivity(activity.getPackageManager()); - if (componentName == null || + + boolean canLaunch = componentName == null || "{com.android.fallback/com.android.fallback.Fallback}". - equals(componentName.toShortString())) { - result.success(false); - } else { - result.success(true); - } + equals(componentName.toShortString())); + result.success(canLaunch); } } diff --git a/packages/url-launcher/example/android/build.gradle b/packages/url-launcher/example/android/build.gradle index baaf22d01b40..ee5325df808c 100644 --- a/packages/url-launcher/example/android/build.gradle +++ b/packages/url-launcher/example/android/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:2.2.3' } } diff --git a/packages/url-launcher/example/lib/main.dart b/packages/url-launcher/example/lib/main.dart index 9e34ea45d83b..143619cd8fef 100644 --- a/packages/url-launcher/example/lib/main.dart +++ b/packages/url-launcher/example/lib/main.dart @@ -15,7 +15,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( - title: 'URL Laucher', + title: 'URL Launcher', theme: new ThemeData( primarySwatch: Colors.blue, ), @@ -37,7 +37,7 @@ class _MyHomePageState extends State { void _launchUrl() { setState(() { - _launched = _launch('https://flutter.io'); + _launched = _launch('htts://flutter.io'); }); } @@ -80,7 +80,7 @@ class _MyHomePageState extends State { ), ], ), - new FutureBuilder(future: _launched, builder: _launchStatus), + new FutureBuilder(future: _launched, builder: _launchStatus), ], ), ), diff --git a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m index 53622fabdb3c..1b31ddb08328 100644 --- a/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m +++ b/packages/url-launcher/ios/Classes/UrlLauncherPlugin.m @@ -7,14 +7,14 @@ - (instancetype)initWithController:(FlutterViewController*)controller { self = [super init]; if (self) { FlutterMethodChannel* channel = [FlutterMethodChannel - methodChannelWithName:@"plugins.flutter.io/URLLauncher" + methodChannelWithName:@"plugins.flutter.io/url_launcher" binaryMessenger:controller]; [channel setMethodCallHandler:^(FlutterMethodCall *call, FlutterResult result) { NSString* url = call.arguments; - if ([@"UrlLauncher.canLaunch" isEqualToString:call.method]) { + if ([@"canLaunch" isEqualToString:call.method]) { result(@([self canLaunchURL:url])); - } else if ([@"UrlLauncher.launch" isEqualToString:call.method]) { + } else if ([@"launch" isEqualToString:call.method]) { [self launchURL:url result:result]; } else { result(FlutterMethodNotImplemented); diff --git a/packages/url-launcher/lib/url_launcher.dart b/packages/url-launcher/lib/url_launcher.dart index 2847c01020e2..999ee0c28a87 100644 --- a/packages/url-launcher/lib/url_launcher.dart +++ b/packages/url-launcher/lib/url_launcher.dart @@ -6,20 +6,20 @@ import 'dart:async'; import 'package:flutter/services.dart'; -const _channel = const MethodChannel('plugins.flutter.io/URLLauncher'); +const _channel = const MethodChannel('plugins.flutter.io/url_launcher'); /// Parse the specified URL string and delegate handling of the same to the /// underlying platform. Future launch(String urlString) { return _channel.invokeMethod( - 'UrlLauncher.launch', + 'launch', urlString, ); } Future canLaunch(String urlString) { return _channel.invokeMethod( - 'UrlLauncher.canLaunch', + 'canLaunch', urlString, ); } From b7ec3d6ba962460693f87474d86816f540e9c98b Mon Sep 17 00:00:00 2001 From: Sarah Winther Zakarias Date: Thu, 27 Apr 2017 21:05:02 +0200 Subject: [PATCH 10/11] fix url --- packages/url-launcher/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/url-launcher/example/lib/main.dart b/packages/url-launcher/example/lib/main.dart index 143619cd8fef..c98b7fd6bb7a 100644 --- a/packages/url-launcher/example/lib/main.dart +++ b/packages/url-launcher/example/lib/main.dart @@ -37,7 +37,7 @@ class _MyHomePageState extends State { void _launchUrl() { setState(() { - _launched = _launch('htts://flutter.io'); + _launched = _launch('https://flutter.io'); }); } From f97821c50644d8cce6ae7f5c2065cb9041fdefa4 Mon Sep 17 00:00:00 2001 From: Sarah Winther Zakarias Date: Thu, 27 Apr 2017 21:35:21 +0200 Subject: [PATCH 11/11] fix logic --- .../io/flutter/plugins/url_launcher/UrlLauncherPlugin.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java index b2a5fba28736..347a6f68af33 100644 --- a/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java +++ b/packages/url-launcher/android/src/main/java/io/flutter/plugins/url_launcher/UrlLauncherPlugin.java @@ -54,9 +54,9 @@ private void canLaunch(String url, Result result) { launchIntent.setData(Uri.parse(url)); ComponentName componentName = launchIntent.resolveActivity(activity.getPackageManager()); - boolean canLaunch = componentName == null || - "{com.android.fallback/com.android.fallback.Fallback}". - equals(componentName.toShortString())); + boolean canLaunch = componentName != null && + !"{com.android.fallback/com.android.fallback.Fallback}". + equals(componentName.toShortString()); result.success(canLaunch); } }