commit 0d7452aa32cb20988288cfe6a89a0b58d1a257e1 Author: aminborhani21 Date: Mon Sep 14 17:42:17 2026 +0330 Initial diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..493a0b4 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,66 @@ +# Below is a list of people and organizations that have contributed +# to the Flutter project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. +The Chromium Authors +German Saprykin +Benjamin Sauer +larsenthomasj@gmail.com +Ali Bitek +Pol Batlló +Anatoly Pulyaevskiy +Hayden Flinner +Stefano Rodriguez +Salvatore Giordano +Brian Armstrong +Paul DeMarco +Fabricio Nogueira +Simon Lightfoot +Ashton Thomas +Thomas Danner +Diego Velásquez +Hajime Nakamura +Tuyển Vũ Xuân +Miguel Ruivo +Sarthak Verma +Mike Diarmid +Invertase +Elliot Hesp +Vince Varga +Aawaz Gyawali +EUI Limited +Katarina Sheremet +Thomas Stockx +Sarbagya Dhaubanjar +Ozkan Eksi +Rishab Nayak +ko2ic +Jonathan Younger +Jose Sanchez +Debkanchan Samadder +Audrius Karosevicius +Lukasz Piliszczuk +SoundReply Solutions GmbH +Rafal Wachol +Pau Picas +Christian Weder +Alexandru Tuca +Christian Weder +Rhodes Davis Jr. +Luigi Agosti +Quentin Le Guennec +Koushik Ravikumar +Nissim Dsilva +Giancarlo Rocha +Ryo Miyake +Théo Champion +Kazuki Yamaguchi +Eitan Schwartz +Chris Rutkowski +Juan Alvarez +Aleksandr Yurkovskiy +Anton Borries +Alex Li +Rahul Raj <64.rahulraj@gmail.com> diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d0953fd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,90 @@ +## 6.3.2 + +* Updates to Pigeon v22. +* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3. + +## 6.3.1 + +* Fixes a compile error when comforming UIApplication to Launcher in iOS 18 Beta 3. + +## 6.3.0 + +* Adds Swift Package Manager compatibility. + +## 6.2.5 + +* Adds explicit imports for UIKit. +* Updates minimum iOS version to 12.0 and minimum Flutter version to 3.16.6. + +## 6.2.4 + +* Adds privacy manifest. + +## 6.2.3 + +* Updates minimum required plugin_platform_interface version to 2.1.7. + +## 6.2.2 + +* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0. +* Fixes lint warnings. + +## 6.2.1 + +* Migrates plugin from Objective-C to Swift. + +## 6.2.0 + +* Implements `supportsMode` and `supportsCloseForMode`. + +## 6.1.5 + +* Adds pub topics to package metadata. +* Updates minimum supported SDK version to Flutter 3.7/Dart 2.19. + +## 6.1.4 + +* Updates pigeon to fix warnings with clang 15. + +## 6.1.3 + +* Switches to Pigeon for internal implementation. + +## 6.1.2 + +* Clarifies explanation of endorsement in README. + +## 6.1.1 + +* Updates links for the merge of flutter/plugins into flutter/packages. + +## 6.1.0 + +* Updates minimum Flutter version to 3.3 and iOS 11. + +## 6.0.18 + +* Updates code for stricter lint checks. +* Updates minimum Flutter version to 2.10. + +## 6.0.17 + +* Suppresses warnings for pre-iOS-13 codepaths. + +## 6.0.16 + +* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors + lint warnings. + +## 6.0.15 + +* Switches to an in-package method channel implementation. + +## 6.0.14 + +* Updates code for new analysis options. +* Removes dependency on `meta`. + +## 6.0.13 + +* Splits from `url_launcher` as a federated implementation. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c6823b8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,25 @@ +Copyright 2013 The Flutter Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e768432 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# url\_launcher\_ios + +The iOS implementation of [`url_launcher`][1]. + +## Usage + +This package is [endorsed][2], which means you can simply use `url_launcher` +normally. This package will be automatically included in your app when you do, +so you do not need to add it to your `pubspec.yaml`. + +However, if you `import` this package to use any of its APIs directly, you +should add it to your `pubspec.yaml` as usual. + +[1]: https://pub.dev/packages/url_launcher +[2]: https://flutter.dev/to/endorsed-federated-plugin diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..96b8bb1 --- /dev/null +++ b/example/README.md @@ -0,0 +1,9 @@ +# Platform Implementation Test App + +This is a test app for manual testing and automated integration testing +of this platform implementation. It is not intended to demonstrate actual use of +this package, since the intent is that plugin clients use the app-facing +package. + +Unless you are making changes to this implementation package, this example is +very unlikely to be relevant. diff --git a/example/integration_test/url_launcher_test.dart b/example/integration_test/url_launcher_test.dart new file mode 100644 index 0000000..b8f1905 --- /dev/null +++ b/example/integration_test/url_launcher_test.dart @@ -0,0 +1,26 @@ +// Copyright 2013 The Flutter 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 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('canLaunch', (WidgetTester _) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + + expect(await launcher.canLaunch('randomstring'), false); + + // Generally all devices should have some default browser. + expect(await launcher.canLaunch('http://flutter.dev'), true); + + // SMS handling is available by default on test devices. + expect(await launcher.canLaunch('sms:5555555555'), true); + + // tel: and mailto: links may not be openable on every device. iOS + // simulators notably can't open these link types. + }); +} diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..b3aaa73 --- /dev/null +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + UIRequiredDeviceCapabilities + + arm64 + + MinimumOSVersion + 12.0 + + diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..9803018 --- /dev/null +++ b/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "Generated.xcconfig" +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..a4a8c60 --- /dev/null +++ b/example/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include "Generated.xcconfig" +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..c9339a0 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..86e220f --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,771 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1D9FF3342A90170000F89C85 /* URLLauncherTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D9FF3332A90170000F89C85 /* URLLauncherTests.swift */; }; + 1DBE6EDE2A92479000B6525C /* URLLauncherUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DBE6EDD2A92479000B6525C /* URLLauncherUITests.swift */; }; + 2D92223F1EC1DA93007564B0 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D92223E1EC1DA93007564B0 /* GeneratedPluginRegistrant.m */; }; + 2E37D9A274B2EACB147AC51B /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 856D0913184F79C678A42603 /* libPods-Runner.a */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + B8140773523F70A044426500 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 487A1B5A2ECB3E406FD62FE3 /* libPods-RunnerTests.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + F7151F4D26604CFB0028CB91 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; + F7151F5B26604D060028CB91 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1D9FF3332A90170000F89C85 /* URLLauncherTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLLauncherTests.swift; sourceTree = ""; }; + 1DBE6EDD2A92479000B6525C /* URLLauncherUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLLauncherUITests.swift; sourceTree = ""; }; + 2D92223D1EC1DA93007564B0 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GeneratedPluginRegistrant.h; path = Runner/GeneratedPluginRegistrant.h; sourceTree = ""; }; + 2D92223E1EC1DA93007564B0 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GeneratedPluginRegistrant.m; path = Runner/GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 487A1B5A2ECB3E406FD62FE3 /* libPods-RunnerTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 666BCD7C181C34F8BE58929B /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 836316F9AEA584411312E29F /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 856D0913184F79C678A42603 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A84BFEE343F54B983D1B67EB /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + D25C434271ACF6555E002440 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + F7151F4826604CFB0028CB91 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + F7151F4C26604CFB0028CB91 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F7151F5626604D060028CB91 /* RunnerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + F7151F5A26604D060028CB91 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, + 2E37D9A274B2EACB147AC51B /* libPods-Runner.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F7151F4526604CFB0028CB91 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + B8140773523F70A044426500 /* libPods-RunnerTests.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F7151F5326604D060028CB91 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 840012C8B5EDBCF56B0E4AC1 /* Pods */ = { + isa = PBXGroup; + children = ( + 836316F9AEA584411312E29F /* Pods-Runner.debug.xcconfig */, + A84BFEE343F54B983D1B67EB /* Pods-Runner.release.xcconfig */, + 666BCD7C181C34F8BE58929B /* Pods-RunnerTests.debug.xcconfig */, + D25C434271ACF6555E002440 /* Pods-RunnerTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 2D92223D1EC1DA93007564B0 /* GeneratedPluginRegistrant.h */, + 2D92223E1EC1DA93007564B0 /* GeneratedPluginRegistrant.m */, + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + F7151F4926604CFB0028CB91 /* RunnerTests */, + F7151F5726604D060028CB91 /* RunnerUITests */, + 97C146EF1CF9000F007C117D /* Products */, + 840012C8B5EDBCF56B0E4AC1 /* Pods */, + CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + F7151F4826604CFB0028CB91 /* RunnerTests.xctest */, + F7151F5626604D060028CB91 /* RunnerUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + CF3B75C9A7D2FA2A4C99F110 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 856D0913184F79C678A42603 /* libPods-Runner.a */, + 487A1B5A2ECB3E406FD62FE3 /* libPods-RunnerTests.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + F7151F4926604CFB0028CB91 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + F7151F4C26604CFB0028CB91 /* Info.plist */, + 1D9FF3332A90170000F89C85 /* URLLauncherTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + F7151F5726604D060028CB91 /* RunnerUITests */ = { + isa = PBXGroup; + children = ( + F7151F5A26604D060028CB91 /* Info.plist */, + 1DBE6EDD2A92479000B6525C /* URLLauncherUITests.swift */, + ); + path = RunnerUITests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + AB1344B0443C71CD721E1BB7 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; + F7151F4726604CFB0028CB91 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = F7151F5126604CFB0028CB91 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + DD4687403C4F35FCD2994FDE /* [CP] Check Pods Manifest.lock */, + F7151F4426604CFB0028CB91 /* Sources */, + F7151F4526604CFB0028CB91 /* Frameworks */, + F7151F4626604CFB0028CB91 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + F7151F4E26604CFB0028CB91 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = F7151F4826604CFB0028CB91 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + F7151F5526604D060028CB91 /* RunnerUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = F7151F5D26604D060028CB91 /* Build configuration list for PBXNativeTarget "RunnerUITests" */; + buildPhases = ( + F7151F5226604D060028CB91 /* Sources */, + F7151F5326604D060028CB91 /* Frameworks */, + F7151F5426604D060028CB91 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + F7151F5C26604D060028CB91 /* PBXTargetDependency */, + ); + name = RunnerUITests; + productName = RunnerUITests; + productReference = F7151F5626604D060028CB91 /* RunnerUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = "The Flutter Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = S8QB4VV633; + }; + F7151F4726604CFB0028CB91 = { + CreatedOnToolsVersion = 12.5; + ProvisioningStyle = Automatic; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + F7151F5526604D060028CB91 = { + CreatedOnToolsVersion = 12.5; + ProvisioningStyle = Automatic; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, + ); + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + F7151F4726604CFB0028CB91 /* RunnerTests */, + F7151F5526604D060028CB91 /* RunnerUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F7151F4626604CFB0028CB91 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F7151F5426604D060028CB91 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; + }; + AB1344B0443C71CD721E1BB7 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + DD4687403C4F35FCD2994FDE /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 2D92223F1EC1DA93007564B0 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F7151F4426604CFB0028CB91 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1D9FF3342A90170000F89C85 /* URLLauncherTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F7151F5226604D060028CB91 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1DBE6EDE2A92479000B6525C /* URLLauncherUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + F7151F4E26604CFB0028CB91 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = F7151F4D26604CFB0028CB91 /* PBXContainerItemProxy */; + }; + F7151F5C26604D060028CB91 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = F7151F5B26604D060028CB91 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.urlLauncher; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.urlLauncher; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + F7151F4F26604CFB0028CB91 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 666BCD7C181C34F8BE58929B /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = RunnerTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Debug; + }; + F7151F5026604CFB0028CB91 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D25C434271ACF6555E002440 /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = RunnerTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner"; + }; + name = Release; + }; + F7151F5E26604D060028CB91 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = RunnerUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_TARGET_NAME = Runner; + }; + name = Debug; + }; + F7151F5F26604D060028CB91 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = RunnerUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_TARGET_NAME = Runner; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F7151F5126604CFB0028CB91 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F7151F4F26604CFB0028CB91 /* Debug */, + F7151F5026604CFB0028CB91 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F7151F5D26604D060028CB91 /* Build configuration list for PBXNativeTarget "RunnerUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F7151F5E26604D060028CB91 /* Debug */, + F7151F5F26604D060028CB91 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..ca0fd11 --- /dev/null +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..21a3cc1 --- /dev/null +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/ios/Runner/AppDelegate.h b/example/ios/Runner/AppDelegate.h new file mode 100644 index 0000000..0681d28 --- /dev/null +++ b/example/ios/Runner/AppDelegate.h @@ -0,0 +1,10 @@ +// Copyright 2013 The Flutter 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 +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m new file mode 100644 index 0000000..83f0621 --- /dev/null +++ b/example/ios/Runner/AppDelegate.m @@ -0,0 +1,17 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "AppDelegate.h" +#include "GeneratedPluginRegistrant.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + [super application:application didFinishLaunchingWithOptions:launchOptions]; + return YES; +} + +@end diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d22f10b --- /dev/null +++ b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,116 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..28c6bf0 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..f091b6b Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cde121 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..d0ef06e Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..dcdc230 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..c8f9ed8 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..75b2d16 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..c4df70d Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..6a84f41 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..d0e1f58 Binary files /dev/null and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..ebf48f6 --- /dev/null +++ b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/ios/Runner/Base.lproj/Main.storyboard b/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist new file mode 100644 index 0000000..be02cc9 --- /dev/null +++ b/example/ios/Runner/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + url_launcher_example + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/example/ios/Runner/main.m b/example/ios/Runner/main.m new file mode 100644 index 0000000..f143297 --- /dev/null +++ b/example/ios/Runner/main.m @@ -0,0 +1,13 @@ +// Copyright 2013 The Flutter 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 +#import +#import "AppDelegate.h" + +int main(int argc, char *argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/example/ios/RunnerTests/Info.plist b/example/ios/RunnerTests/Info.plist new file mode 100644 index 0000000..64d65ca --- /dev/null +++ b/example/ios/RunnerTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/example/ios/RunnerTests/URLLauncherTests.swift b/example/ios/RunnerTests/URLLauncherTests.swift new file mode 100644 index 0000000..966a3d6 --- /dev/null +++ b/example/ios/RunnerTests/URLLauncherTests.swift @@ -0,0 +1,151 @@ +// Copyright 2013 The Flutter 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 Flutter +import XCTest + +@testable import url_launcher_ios + +// Tests whether NSURL parsing is strict. When linking against the iOS 17 SDK or later, +// NSURL uses a more lenient parser which will not return nil. +private func urlParsingIsStrict() -> Bool { + return URL(string: "b a d U R L") == nil +} + +final class URLLauncherTests: XCTestCase { + + private func createPlugin() -> URLLauncherPlugin { + let launcher = FakeLauncher() + return URLLauncherPlugin(launcher: launcher) + } + + private func createPlugin(launcher: FakeLauncher) -> URLLauncherPlugin { + return URLLauncherPlugin(launcher: launcher) + } + + func testCanLaunchSuccess() { + let result = createPlugin().canLaunchUrl(url: "good://url") + XCTAssertEqual(result, .success) + } + + func testCanLaunchFailure() { + let result = createPlugin().canLaunchUrl(url: "bad://url") + XCTAssertEqual(result, .failure) + } + + func testCanLaunchFailureWithInvalidURL() { + let result = createPlugin().canLaunchUrl(url: "urls can't have spaces") + + if urlParsingIsStrict() { + XCTAssertEqual(result, .invalidUrl) + } else { + XCTAssertEqual(result, .failure) + } + } + + func testLaunchSuccess() { + let expectation = XCTestExpectation(description: "completion called") + createPlugin().launchUrl(url: "good://url", universalLinksOnly: false) { result in + switch result { + case .success(let details): + XCTAssertEqual(details, .success) + case .failure(let error): + XCTFail("Unexpected error: \(error)") + } + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + } + + func testLaunchFailure() { + let expectation = XCTestExpectation(description: "completion called") + createPlugin().launchUrl(url: "bad://url", universalLinksOnly: false) { result in + switch result { + case .success(let details): + XCTAssertEqual(details, .failure) + case .failure(let error): + XCTFail("Unexpected error: \(error)") + } + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + } + + func testLaunchFailureWithInvalidURL() { + let expectation = XCTestExpectation(description: "completion called") + createPlugin().launchUrl(url: "urls can't have spaces", universalLinksOnly: false) { result in + switch result { + case .success(let details): + if urlParsingIsStrict() { + XCTAssertEqual(details, .invalidUrl) + } else { + XCTAssertEqual(details, .failure) + } + case .failure(let error): + XCTFail("Unexpected error: \(error)") + } + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + } + + func testLaunchWithoutUniversalLinks() { + let launcher = FakeLauncher() + let plugin = createPlugin(launcher: launcher) + + let expectation = XCTestExpectation(description: "completion called") + plugin.launchUrl(url: "good://url", universalLinksOnly: false) { result in + switch result { + case .success(let details): + XCTAssertEqual(details, .success) + case .failure(let error): + XCTFail("Unexpected error: \(error)") + } + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + XCTAssertEqual(launcher.passedOptions?[.universalLinksOnly] as? Bool, false) + } + + func testLaunchWithUniversalLinks() { + let launcher = FakeLauncher() + let plugin = createPlugin(launcher: launcher) + + let expectation = XCTestExpectation(description: "completion called") + plugin.launchUrl(url: "good://url", universalLinksOnly: true) { result in + switch result { + case .success(let details): + XCTAssertEqual(details, .success) + case .failure(let error): + XCTFail("Unexpected error: \(error)") + } + expectation.fulfill() + } + + wait(for: [expectation], timeout: 1) + XCTAssertEqual(launcher.passedOptions?[.universalLinksOnly] as? Bool, true) + } + +} + +final private class FakeLauncher: NSObject, Launcher { + var passedOptions: [UIApplication.OpenExternalURLOptionsKey: Any]? + + func canOpenURL(_ url: URL) -> Bool { + url.scheme == "good" + } + + func open( + _ url: URL, + options: [UIApplication.OpenExternalURLOptionsKey: Any], + completionHandler completion: ((Bool) -> Void)? + ) { + self.passedOptions = options + completion?(url.scheme == "good") + } +} diff --git a/example/ios/RunnerUITests/Info.plist b/example/ios/RunnerUITests/Info.plist new file mode 100644 index 0000000..64d65ca --- /dev/null +++ b/example/ios/RunnerUITests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/example/ios/RunnerUITests/URLLauncherUITests.swift b/example/ios/RunnerUITests/URLLauncherUITests.swift new file mode 100644 index 0000000..20b8c1b --- /dev/null +++ b/example/ios/RunnerUITests/URLLauncherUITests.swift @@ -0,0 +1,42 @@ +// Copyright 2013 The Flutter 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 XCTest + +class URLLauncherUITests: XCTestCase { + var app: XCUIApplication! + + override func setUp() { + continueAfterFailure = false + + app = XCUIApplication() + app.launch() + } + + func testLaunch() { + let app = self.app! + + let buttonNames: [String] = [ + "Launch in app", "Launch in app(JavaScript ON)", "Launch in app(DOM storage ON)", + "Launch a universal link in a native app, fallback to Safari.(Youtube)", + ] + for buttonName in buttonNames { + let button = app.buttons[buttonName] + XCTAssertTrue(button.waitForExistence(timeout: 30.0)) + XCTAssertEqual(app.webViews.count, 0) + button.tap() + let webView = app.webViews.firstMatch + XCTAssertTrue(webView.waitForExistence(timeout: 30.0)) + XCTAssertTrue(app.buttons["ForwardButton"].waitForExistence(timeout: 30.0)) + XCTAssertTrue(app.buttons["Share"].exists) + XCTAssertTrue(app.buttons["OpenInSafariButton"].exists) + let doneButton = app.buttons["Done"] + XCTAssertTrue(doneButton.waitForExistence(timeout: 30.0)) + // This should just be doneButton.tap, but for some reason that stopped working in Xcode 15; + // tapping via coordinate works, however. + doneButton.coordinate(withNormalizedOffset: CGVector()).withOffset(CGVector(dx: 10, dy: 10)) + .tap() + } + } +} diff --git a/example/lib/main.dart b/example/lib/main.dart new file mode 100644 index 0000000..f01624f --- /dev/null +++ b/example/lib/main.dart @@ -0,0 +1,242 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'URL Launcher', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: const MyHomePage(title: 'URL Launcher'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + Future? _launched; + String _phone = ''; + + Future _launchInBrowser(String url) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + if (await launcher.canLaunch(url)) { + await launcher.launch( + url, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: {'my_header_key': 'my_header_value'}, + ); + } else { + throw Exception('Could not launch $url'); + } + } + + Future _launchInWebViewOrVC(String url) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + if (await launcher.canLaunch(url)) { + await launcher.launch( + url, + useSafariVC: true, + useWebView: true, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: {'my_header_key': 'my_header_value'}, + ); + } else { + throw Exception('Could not launch $url'); + } + } + + Future _launchInWebViewWithJavaScript(String url) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + if (await launcher.canLaunch(url)) { + await launcher.launch( + url, + useSafariVC: true, + useWebView: true, + enableJavaScript: true, + enableDomStorage: false, + universalLinksOnly: false, + headers: {}, + ); + } else { + throw Exception('Could not launch $url'); + } + } + + Future _launchInWebViewWithDomStorage(String url) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + if (await launcher.canLaunch(url)) { + await launcher.launch( + url, + useSafariVC: true, + useWebView: true, + enableJavaScript: false, + enableDomStorage: true, + universalLinksOnly: false, + headers: {}, + ); + } else { + throw Exception('Could not launch $url'); + } + } + + Future _launchUniversalLinkIos(String url) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + if (await launcher.canLaunch(url)) { + final bool nativeAppLaunchSucceeded = await launcher.launch( + url, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: true, + headers: {}, + ); + if (!nativeAppLaunchSucceeded) { + await launcher.launch( + url, + useSafariVC: true, + useWebView: true, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: true, + headers: {}, + ); + } + } + } + + Widget _launchStatus(BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else { + return const Text(''); + } + } + + Future _makePhoneCall(String url) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + if (await launcher.canLaunch(url)) { + await launcher.launch( + url, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: true, + headers: {}, + ); + } else { + throw Exception('Could not launch $url'); + } + } + + @override + Widget build(BuildContext context) { + const String toLaunch = 'https://www.cylog.org/headers/'; + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: ListView( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: TextField( + onChanged: (String text) => _phone = text, + decoration: const InputDecoration( + hintText: 'Input the phone number to launch')), + ), + ElevatedButton( + onPressed: () => setState(() { + _launched = _makePhoneCall('tel:$_phone'); + }), + child: const Text('Make phone call'), + ), + const Padding( + padding: EdgeInsets.all(16.0), + child: Text(toLaunch), + ), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchInBrowser(toLaunch); + }), + child: const Text('Launch in browser'), + ), + const Padding(padding: EdgeInsets.all(16.0)), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchInWebViewOrVC(toLaunch); + }), + child: const Text('Launch in app'), + ), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchInWebViewWithJavaScript(toLaunch); + }), + child: const Text('Launch in app(JavaScript ON)'), + ), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchInWebViewWithDomStorage(toLaunch); + }), + child: const Text('Launch in app(DOM storage ON)'), + ), + const Padding(padding: EdgeInsets.all(16.0)), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchUniversalLinkIos(toLaunch); + }), + child: const Text( + 'Launch a universal link in a native app, fallback to Safari.(Youtube)'), + ), + const Padding(padding: EdgeInsets.all(16.0)), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchInWebViewOrVC(toLaunch); + Timer(const Duration(seconds: 5), () { + UrlLauncherPlatform.instance.closeWebView(); + }); + }), + child: const Text('Launch in app + close after 5 seconds'), + ), + const Padding(padding: EdgeInsets.all(16.0)), + FutureBuilder(future: _launched, builder: _launchStatus), + ], + ), + ], + ), + ); + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 0000000..3e25998 --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,29 @@ +name: url_launcher_example +description: Demonstrates how to use the url_launcher plugin. +publish_to: none + +environment: + sdk: ^3.3.0 + flutter: ">=3.19.0" + +dependencies: + flutter: + sdk: flutter + url_launcher_ios: + # When depending on this package from a real application you should use: + # url_launcher_ios: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + url_launcher_platform_interface: ^2.2.0 + +dev_dependencies: + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + plugin_platform_interface: ^2.1.7 + +flutter: + uses-material-design: true diff --git a/example/test_driver/integration_test.dart b/example/test_driver/integration_test.dart new file mode 100644 index 0000000..4f10f2a --- /dev/null +++ b/example/test_driver/integration_test.dart @@ -0,0 +1,7 @@ +// Copyright 2013 The Flutter 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 'package:integration_test/integration_test_driver.dart'; + +Future main() => integrationDriver(); diff --git a/ios/url_launcher_ios.podspec b/ios/url_launcher_ios.podspec new file mode 100644 index 0000000..fa30175 --- /dev/null +++ b/ios/url_launcher_ios.podspec @@ -0,0 +1,26 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html +# +Pod::Spec.new do |s| + s.name = 'url_launcher_ios' + s.version = '0.0.1' + s.summary = 'Flutter plugin for launching a URL.' + s.description = <<-DESC +A Flutter plugin for making the underlying platform (Android or iOS) launch a URL. + DESC + s.homepage = 'https://github.com/flutter/packages/tree/main/packages/url_launcher' + s.license = { :type => 'BSD', :file => '../LICENSE' } + s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } + s.source = { :http => 'https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_ios' } + s.documentation_url = 'https://pub.dev/packages/url_launcher' + s.swift_version = '5.0' + s.source_files = 'url_launcher_ios/Sources/**/*.swift' + s.xcconfig = { + 'LIBRARY_SEARCH_PATHS' => '$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)/ $(SDKROOT)/usr/lib/swift', + 'LD_RUNPATH_SEARCH_PATHS' => '/usr/lib/swift', + } + s.dependency 'Flutter' + s.platform = :ios, '12.0' + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } + s.resource_bundles = {'url_launcher_ios_privacy' => ['url_launcher_ios/Sources/url_launcher_ios/Resources/PrivacyInfo.xcprivacy']} +end diff --git a/ios/url_launcher_ios/Package.swift b/ios/url_launcher_ios/Package.swift new file mode 100644 index 0000000..5dbdd8a --- /dev/null +++ b/ios/url_launcher_ios/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +// Copyright 2013 The Flutter 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 PackageDescription + +let package = Package( + name: "url_launcher_ios", + platforms: [ + .iOS("12.0") + ], + products: [ + .library(name: "url-launcher-ios", targets: ["url_launcher_ios"]) + ], + dependencies: [], + targets: [ + .target( + name: "url_launcher_ios", + dependencies: [], + resources: [ + .process("Resources") + ] + ) + ] +) diff --git a/ios/url_launcher_ios/Sources/url_launcher_ios/Launcher.swift b/ios/url_launcher_ios/Sources/url_launcher_ios/Launcher.swift new file mode 100644 index 0000000..1f64b95 --- /dev/null +++ b/ios/url_launcher_ios/Sources/url_launcher_ios/Launcher.swift @@ -0,0 +1,38 @@ +// Copyright 2013 The Flutter 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 UIKit + +/// Protocol for UIApplication methods relating to launching URLs. +/// +/// This protocol exists to allow injecting an alternate implementation for testing. +protocol Launcher { + /// Returns a Boolean value that indicates whether an app is available to handle a URL scheme. + func canOpenURL(_ url: URL) -> Bool + + /// Attempts to asynchronously open the resource at the specified URL. + func open( + _ url: URL, + options: [UIApplication.OpenExternalURLOptionsKey: Any], + completionHandler completion: ((Bool) -> Void)?) +} + +// TODO(hellohuanlin): This wrapper is a workaround for iOS 18 Beta 3 where completionHandler is annotated with @MainActor @Sendable, resulting in compile error when conforming UIApplication to Launcher. We should try again in newer betas. +/// A default URL launcher. +final class DefaultLauncher: Launcher { + func canOpenURL(_ url: URL) -> Bool { + return UIApplication.shared.canOpenURL(url) + } + + func open( + _ url: URL, + options: [UIApplication.OpenExternalURLOptionsKey: Any], + completionHandler completion: ((Bool) -> Void)? + ) { + UIApplication.shared.open( + url, + options: options, + completionHandler: completion) + } +} diff --git a/ios/url_launcher_ios/Sources/url_launcher_ios/Resources/PrivacyInfo.xcprivacy b/ios/url_launcher_ios/Sources/url_launcher_ios/Resources/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..a34b7e2 --- /dev/null +++ b/ios/url_launcher_ios/Sources/url_launcher_ios/Resources/PrivacyInfo.xcprivacy @@ -0,0 +1,14 @@ + + + + + NSPrivacyTrackingDomains + + NSPrivacyAccessedAPITypes + + NSPrivacyCollectedDataTypes + + NSPrivacyTracking + + + diff --git a/ios/url_launcher_ios/Sources/url_launcher_ios/URLLaunchSession.swift b/ios/url_launcher_ios/Sources/url_launcher_ios/URLLaunchSession.swift new file mode 100644 index 0000000..b0761e5 --- /dev/null +++ b/ios/url_launcher_ios/Sources/url_launcher_ios/URLLaunchSession.swift @@ -0,0 +1,63 @@ +// Copyright 2013 The Flutter 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 Flutter +import SafariServices + +typealias OpenInSafariCompletionHandler = (Result) -> Void + +/// A session responsible for launching a URL in Safari and handling its events. +final class URLLaunchSession: NSObject, SFSafariViewControllerDelegate { + + private let completion: OpenInSafariCompletionHandler + private let url: URL + + /// The Safari view controller used for displaying the URL. + let safariViewController: SFSafariViewController + + // A closure to be executed after the Safari view controller finishes. + var didFinish: (() -> Void)? + + /// Initializes a new URLLaunchSession with the provided URL and completion handler. + /// + /// - Parameters: + /// - url: The URL to be opened in Safari. + /// - completion: The completion handler to be called after attempting to open the URL. + init(url: URL, completion: @escaping OpenInSafariCompletionHandler) { + self.url = url + self.completion = completion + self.safariViewController = SFSafariViewController(url: url) + super.init() + self.safariViewController.delegate = self + } + + /// Called when the Safari view controller completes the initial load. + /// + /// - Parameters: + /// - controller: The Safari view controller. + /// - didLoadSuccessfully: Indicates if the initial load was successful. + func safariViewController( + _ controller: SFSafariViewController, + didCompleteInitialLoad didLoadSuccessfully: Bool + ) { + if didLoadSuccessfully { + completion(.success(.success)) + } else { + completion(.success(.failedToLoad)) + } + } + + /// Called when the user finishes using the Safari view controller. + /// + /// - Parameter controller: The Safari view controller. + func safariViewControllerDidFinish(_ controller: SFSafariViewController) { + controller.dismiss(animated: true, completion: nil) + didFinish?() + } + + /// Closes the Safari view controller. + func close() { + safariViewControllerDidFinish(safariViewController) + } +} diff --git a/ios/url_launcher_ios/Sources/url_launcher_ios/URLLauncherPlugin.swift b/ios/url_launcher_ios/Sources/url_launcher_ios/URLLauncherPlugin.swift new file mode 100644 index 0000000..9fdec7e --- /dev/null +++ b/ios/url_launcher_ios/Sources/url_launcher_ios/URLLauncherPlugin.swift @@ -0,0 +1,100 @@ +// Copyright 2013 The Flutter 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 Flutter +import UIKit + +public final class URLLauncherPlugin: NSObject, FlutterPlugin, UrlLauncherApi { + + public static func register(with registrar: FlutterPluginRegistrar) { + let plugin = URLLauncherPlugin() + UrlLauncherApiSetup.setUp(binaryMessenger: registrar.messenger(), api: plugin) + registrar.publish(plugin) + } + + private var currentSession: URLLaunchSession? + private let launcher: Launcher + + private var topViewController: UIViewController? { + // TODO(stuartmorgan) Provide a non-deprecated codepath. See + // https://github.com/flutter/flutter/issues/104117 + UIApplication.shared.keyWindow?.rootViewController?.topViewController + } + + init(launcher: Launcher = DefaultLauncher()) { + self.launcher = launcher + } + + func canLaunchUrl(url: String) -> LaunchResult { + guard let url = URL(string: url) else { + return .invalidUrl + } + let canOpen = launcher.canOpenURL(url) + return canOpen ? .success : .failure + } + + func launchUrl( + url: String, + universalLinksOnly: Bool, + completion: @escaping (Result) -> Void + ) { + guard let url = URL(string: url) else { + completion(.success(.invalidUrl)) + return + } + let options = [UIApplication.OpenExternalURLOptionsKey.universalLinksOnly: universalLinksOnly] + launcher.open(url, options: options) { result in + completion(.success(result ? .success : .failure)) + } + } + + func openUrlInSafariViewController( + url: String, + completion: @escaping (Result) -> Void + ) { + guard let url = URL(string: url) else { + completion(.success(.invalidUrl)) + return + } + + let session = URLLaunchSession(url: url, completion: completion) + currentSession = session + + session.didFinish = { [weak self] in + self?.currentSession = nil + } + topViewController?.present(session.safariViewController, animated: true, completion: nil) + } + + func closeSafariViewController() { + currentSession?.close() + } +} + +/// This method recursively iterates through the view hierarchy +/// to return the top-most view controller. +/// +/// It supports the following scenarios: +/// +/// - The view controller is presenting another view. +/// - The view controller is a UINavigationController. +/// - The view controller is a UITabBarController. +/// +/// @return The top most view controller. +extension UIViewController { + var topViewController: UIViewController { + if let navigationController = self as? UINavigationController { + return navigationController.viewControllers.last?.topViewController + ?? navigationController + .visibleViewController ?? navigationController + } + if let tabBarController = self as? UITabBarController { + return tabBarController.selectedViewController?.topViewController ?? tabBarController + } + if let presented = presentedViewController { + return presented.topViewController + } + return self + } +} diff --git a/ios/url_launcher_ios/Sources/url_launcher_ios/messages.g.swift b/ios/url_launcher_ios/Sources/url_launcher_ios/messages.g.swift new file mode 100644 index 0000000..4c9c469 --- /dev/null +++ b/ios/url_launcher_ios/Sources/url_launcher_ios/messages.g.swift @@ -0,0 +1,242 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Autogenerated from Pigeon (v22.6.4), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +import Foundation + +#if os(iOS) + import Flutter +#elseif os(macOS) + import FlutterMacOS +#else + #error("Unsupported platform.") +#endif + +/// Error class for passing custom error details to Dart side. +final class PigeonError: Error { + let code: String + let message: String? + let details: Any? + + init(code: String, message: String?, details: Any?) { + self.code = code + self.message = message + self.details = details + } + + var localizedDescription: String { + return + "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" + } +} + +private func wrapResult(_ result: Any?) -> [Any?] { + return [result] +} + +private func wrapError(_ error: Any) -> [Any?] { + if let pigeonError = error as? PigeonError { + return [ + pigeonError.code, + pigeonError.message, + pigeonError.details, + ] + } + if let flutterError = error as? FlutterError { + return [ + flutterError.code, + flutterError.message, + flutterError.details, + ] + } + return [ + "\(error)", + "\(type(of: error))", + "Stacktrace: \(Thread.callStackSymbols)", + ] +} + +private func isNullish(_ value: Any?) -> Bool { + return value is NSNull || value == nil +} + +private func nilOrValue(_ value: Any?) -> T? { + if value is NSNull { return nil } + return value as! T? +} + +/// Possible outcomes of launching a URL. +enum LaunchResult: Int { + /// The URL was successfully launched (or could be, for `canLaunchUrl`). + case success = 0 + /// There was no handler available for the URL. + case failure = 1 + /// The URL could not be launched because it is invalid. + case invalidUrl = 2 +} + +/// Possible outcomes of handling a URL within the application. +enum InAppLoadResult: Int { + /// The URL was successfully loaded. + case success = 0 + /// The URL did not load successfully. + case failedToLoad = 1 + /// The URL could not be launched because it is invalid. + case invalidUrl = 2 +} + +private class messagesPigeonCodecReader: FlutterStandardReader { + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 129: + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) + if let enumResultAsInt = enumResultAsInt { + return LaunchResult(rawValue: enumResultAsInt) + } + return nil + case 130: + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) + if let enumResultAsInt = enumResultAsInt { + return InAppLoadResult(rawValue: enumResultAsInt) + } + return nil + default: + return super.readValue(ofType: type) + } + } +} + +private class messagesPigeonCodecWriter: FlutterStandardWriter { + override func writeValue(_ value: Any) { + if let value = value as? LaunchResult { + super.writeByte(129) + super.writeValue(value.rawValue) + } else if let value = value as? InAppLoadResult { + super.writeByte(130) + super.writeValue(value.rawValue) + } else { + super.writeValue(value) + } + } +} + +private class messagesPigeonCodecReaderWriter: FlutterStandardReaderWriter { + override func reader(with data: Data) -> FlutterStandardReader { + return messagesPigeonCodecReader(data: data) + } + + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + return messagesPigeonCodecWriter(data: data) + } +} + +class messagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { + static let shared = messagesPigeonCodec(readerWriter: messagesPigeonCodecReaderWriter()) +} + +/// Generated protocol from Pigeon that represents a handler of messages from Flutter. +protocol UrlLauncherApi { + /// Checks whether a URL can be loaded. + func canLaunchUrl(url: String) throws -> LaunchResult + /// Opens the URL externally, returning the status of launching it. + func launchUrl( + url: String, universalLinksOnly: Bool, + completion: @escaping (Result) -> Void) + /// Opens the URL in an in-app SFSafariViewController, returning the results + /// of loading it. + func openUrlInSafariViewController( + url: String, completion: @escaping (Result) -> Void) + /// Closes the view controller opened by [openUrlInSafariViewController]. + func closeSafariViewController() throws +} + +/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. +class UrlLauncherApiSetup { + static var codec: FlutterStandardMessageCodec { messagesPigeonCodec.shared } + /// Sets up an instance of `UrlLauncherApi` to handle messages through the `binaryMessenger`. + static func setUp( + binaryMessenger: FlutterBinaryMessenger, api: UrlLauncherApi?, messageChannelSuffix: String = "" + ) { + let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" + /// Checks whether a URL can be loaded. + let canLaunchUrlChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.canLaunchUrl\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + canLaunchUrlChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let urlArg = args[0] as! String + do { + let result = try api.canLaunchUrl(url: urlArg) + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + canLaunchUrlChannel.setMessageHandler(nil) + } + /// Opens the URL externally, returning the status of launching it. + let launchUrlChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.launchUrl\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + launchUrlChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let urlArg = args[0] as! String + let universalLinksOnlyArg = args[1] as! Bool + api.launchUrl(url: urlArg, universalLinksOnly: universalLinksOnlyArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + launchUrlChannel.setMessageHandler(nil) + } + /// Opens the URL in an in-app SFSafariViewController, returning the results + /// of loading it. + let openUrlInSafariViewControllerChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.openUrlInSafariViewController\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + openUrlInSafariViewControllerChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let urlArg = args[0] as! String + api.openUrlInSafariViewController(url: urlArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + openUrlInSafariViewControllerChannel.setMessageHandler(nil) + } + /// Closes the view controller opened by [openUrlInSafariViewController]. + let closeSafariViewControllerChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.closeSafariViewController\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + closeSafariViewControllerChannel.setMessageHandler { _, reply in + do { + try api.closeSafariViewController() + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + closeSafariViewControllerChannel.setMessageHandler(nil) + } + } +} diff --git a/lib/src/messages.g.dart b/lib/src/messages.g.dart new file mode 100644 index 0000000..b496303 --- /dev/null +++ b/lib/src/messages.g.dart @@ -0,0 +1,208 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// Autogenerated from Pigeon (v22.6.4), do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers + +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; + +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; +import 'package:flutter/services.dart'; + +PlatformException _createConnectionError(String channelName) { + return PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); +} + +/// Possible outcomes of launching a URL. +enum LaunchResult { + /// The URL was successfully launched (or could be, for `canLaunchUrl`). + success, + + /// There was no handler available for the URL. + failure, + + /// The URL could not be launched because it is invalid. + invalidUrl, +} + +/// Possible outcomes of handling a URL within the application. +enum InAppLoadResult { + /// The URL was successfully loaded. + success, + + /// The URL did not load successfully. + failedToLoad, + + /// The URL could not be launched because it is invalid. + invalidUrl, +} + +class _PigeonCodec extends StandardMessageCodec { + const _PigeonCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is LaunchResult) { + buffer.putUint8(129); + writeValue(buffer, value.index); + } else if (value is InAppLoadResult) { + buffer.putUint8(130); + writeValue(buffer, value.index); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 129: + final int? value = readValue(buffer) as int?; + return value == null ? null : LaunchResult.values[value]; + case 130: + final int? value = readValue(buffer) as int?; + return value == null ? null : InAppLoadResult.values[value]; + default: + return super.readValueOfType(type, buffer); + } + } +} + +class UrlLauncherApi { + /// Constructor for [UrlLauncherApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + UrlLauncherApi( + {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + final BinaryMessenger? pigeonVar_binaryMessenger; + + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); + + final String pigeonVar_messageChannelSuffix; + + /// Checks whether a URL can be loaded. + Future canLaunchUrl(String url) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.canLaunchUrl$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([url]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as LaunchResult?)!; + } + } + + /// Opens the URL externally, returning the status of launching it. + Future launchUrl(String url, bool universalLinksOnly) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.launchUrl$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = await pigeonVar_channel + .send([url, universalLinksOnly]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as LaunchResult?)!; + } + } + + /// Opens the URL in an in-app SFSafariViewController, returning the results + /// of loading it. + Future openUrlInSafariViewController(String url) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.openUrlInSafariViewController$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([url]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as InAppLoadResult?)!; + } + } + + /// Closes the view controller opened by [openUrlInSafariViewController]. + Future closeSafariViewController() async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.closeSafariViewController$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } +} diff --git a/lib/url_launcher_ios.dart b/lib/url_launcher_ios.dart new file mode 100644 index 0000000..bb289ab --- /dev/null +++ b/lib/url_launcher_ios.dart @@ -0,0 +1,172 @@ +// Copyright 2013 The Flutter 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 'package:flutter/foundation.dart' show visibleForTesting; +import 'package:flutter/services.dart'; +import 'package:url_launcher_platform_interface/link.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + +import 'src/messages.g.dart'; + +/// An implementation of [UrlLauncherPlatform] for iOS. +class UrlLauncherIOS extends UrlLauncherPlatform { + /// Creates a new plugin implementation instance. + UrlLauncherIOS({ + @visibleForTesting UrlLauncherApi? api, + }) : _hostApi = api ?? UrlLauncherApi(); + + final UrlLauncherApi _hostApi; + + /// Registers this class as the default instance of [UrlLauncherPlatform]. + static void registerWith() { + UrlLauncherPlatform.instance = UrlLauncherIOS(); + } + + @override + final LinkDelegate? linkDelegate = null; + + @override + Future canLaunch(String url) async { + final LaunchResult result = await _hostApi.canLaunchUrl(url); + return _mapLaunchResult(result); + } + + @override + Future closeWebView() { + return _hostApi.closeSafariViewController(); + } + + @override + Future launch( + String url, { + required bool useSafariVC, + required bool useWebView, + required bool enableJavaScript, + required bool enableDomStorage, + required bool universalLinksOnly, + required Map headers, + String? webOnlyWindowName, + }) async { + final PreferredLaunchMode mode; + if (useSafariVC) { + mode = PreferredLaunchMode.inAppBrowserView; + } else if (universalLinksOnly) { + mode = PreferredLaunchMode.externalNonBrowserApplication; + } else { + mode = PreferredLaunchMode.externalApplication; + } + return launchUrl( + url, + LaunchOptions( + mode: mode, + webViewConfiguration: InAppWebViewConfiguration( + enableDomStorage: enableDomStorage, + enableJavaScript: enableJavaScript, + headers: headers))); + } + + @override + Future launchUrl(String url, LaunchOptions options) async { + final bool inApp; + switch (options.mode) { + case PreferredLaunchMode.inAppWebView: + case PreferredLaunchMode.inAppBrowserView: + // The iOS implementation doesn't distinguish between these two modes; + // both are treated as inAppBrowserView. + inApp = true; + case PreferredLaunchMode.externalApplication: + case PreferredLaunchMode.externalNonBrowserApplication: + inApp = false; + case PreferredLaunchMode.platformDefault: + // Intentionally treat any new values as platformDefault; support for any + // new mode requires intentional opt-in, otherwise falling back is the + // documented behavior. + // ignore: no_default_cases, unreachable_switch_default + default: + // By default, open web URLs in the application. + inApp = url.startsWith('http:') || url.startsWith('https:'); + } + + if (inApp) { + return _mapInAppLoadResult( + await _hostApi.openUrlInSafariViewController(url), + url: url); + } else { + return _mapLaunchResult(await _hostApi.launchUrl(url, + options.mode == PreferredLaunchMode.externalNonBrowserApplication)); + } + } + + @override + Future supportsMode(PreferredLaunchMode mode) async { + switch (mode) { + case PreferredLaunchMode.platformDefault: + case PreferredLaunchMode.inAppWebView: + case PreferredLaunchMode.inAppBrowserView: + case PreferredLaunchMode.externalApplication: + case PreferredLaunchMode.externalNonBrowserApplication: + return true; + // Default is a desired behavior here since support for new modes is + // always opt-in, and the enum lives in a different package, so silently + // adding "false" for new values is the correct behavior. + // ignore: no_default_cases, unreachable_switch_default + default: + return false; + } + } + + @override + Future supportsCloseForMode(PreferredLaunchMode mode) async { + return mode == PreferredLaunchMode.inAppWebView || + mode == PreferredLaunchMode.inAppBrowserView; + } + + bool _mapLaunchResult(LaunchResult result) { + switch (result) { + case LaunchResult.success: + return true; + case LaunchResult.failure: + return false; + case LaunchResult.invalidUrl: + throw _invalidUrlException(); + } + } + + bool _mapInAppLoadResult(InAppLoadResult result, {required String url}) { + switch (result) { + case InAppLoadResult.success: + return true; + case InAppLoadResult.failedToLoad: + throw _failedSafariViewControllerLoadException(url); + case InAppLoadResult.invalidUrl: + throw _invalidUrlException(); + } + } + + // TODO(stuartmorgan): Remove this as part of standardizing error handling. + // See https://github.com/flutter/flutter/issues/127665 + // + // This PlatformException (including the exact string details, since those + // are a defacto part of the API) is for compatibility with the previous + // native implementation. + PlatformException _invalidUrlException() { + throw PlatformException( + code: 'argument_error', + message: 'Unable to parse URL', + ); + } + + // TODO(stuartmorgan): Remove this as part of standardizing error handling. + // See https://github.com/flutter/flutter/issues/127665 + // + // This PlatformException (including the exact string details, since those + // are a defacto part of the API) is for compatibility with the previous + // native implementation. + PlatformException _failedSafariViewControllerLoadException(String url) { + throw PlatformException( + code: 'Error', + message: 'Error while launching $url', + ); + } +} diff --git a/pigeons/copyright.txt b/pigeons/copyright.txt new file mode 100644 index 0000000..1236b63 --- /dev/null +++ b/pigeons/copyright.txt @@ -0,0 +1,3 @@ +Copyright 2013 The Flutter Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. diff --git a/pigeons/messages.dart b/pigeons/messages.dart new file mode 100644 index 0000000..c7097b4 --- /dev/null +++ b/pigeons/messages.dart @@ -0,0 +1,56 @@ +// Copyright 2013 The Flutter 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 'package:pigeon/pigeon.dart'; + +@ConfigurePigeon(PigeonOptions( + dartOut: 'lib/src/messages.g.dart', + swiftOut: 'ios/url_launcher_ios/Sources/url_launcher_ios/messages.g.swift', + copyrightHeader: 'pigeons/copyright.txt', +)) + +/// Possible outcomes of launching a URL. +enum LaunchResult { + /// The URL was successfully launched (or could be, for `canLaunchUrl`). + success, + + /// There was no handler available for the URL. + failure, + + /// The URL could not be launched because it is invalid. + invalidUrl, +} + +/// Possible outcomes of handling a URL within the application. +enum InAppLoadResult { + /// The URL was successfully loaded. + success, + + /// The URL did not load successfully. + failedToLoad, + + /// The URL could not be launched because it is invalid. + invalidUrl, +} + +@HostApi() +abstract class UrlLauncherApi { + /// Checks whether a URL can be loaded. + @ObjCSelector('canLaunchURL:') + LaunchResult canLaunchUrl(String url); + + /// Opens the URL externally, returning the status of launching it. + @async + @ObjCSelector('launchURL:universalLinksOnly:') + LaunchResult launchUrl(String url, bool universalLinksOnly); + + /// Opens the URL in an in-app SFSafariViewController, returning the results + /// of loading it. + @async + @ObjCSelector('openSafariViewControllerWithURL:') + InAppLoadResult openUrlInSafariViewController(String url); + + /// Closes the view controller opened by [openUrlInSafariViewController]. + void closeSafariViewController(); +} diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..9acb83b --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,37 @@ +name: url_launcher_ios +description: iOS implementation of the url_launcher plugin. +repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_ios +issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 +version: 6.3.2 + +environment: + sdk: ^3.1.0 + flutter: ">=3.19.0" + +flutter: + plugin: + implements: url_launcher + platforms: + ios: + pluginClass: URLLauncherPlugin + dartPluginClass: UrlLauncherIOS + +dependencies: + flutter: + sdk: flutter + url_launcher_platform_interface: ^2.2.0 + +dev_dependencies: + build_runner: ^2.3.3 + flutter_test: + sdk: flutter + mockito: ^5.4.4 + pigeon: ^22.6.4 + plugin_platform_interface: ^2.1.7 + test: ^1.16.3 + +topics: + - links + - os-integration + - url-launcher + - urls diff --git a/test/url_launcher_ios_test.dart b/test/url_launcher_ios_test.dart new file mode 100644 index 0000000..195db63 --- /dev/null +++ b/test/url_launcher_ios_test.dart @@ -0,0 +1,370 @@ +// Copyright 2013 The Flutter 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 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/annotations.dart'; +import 'package:mockito/mockito.dart'; +import 'package:url_launcher_ios/src/messages.g.dart'; +import 'package:url_launcher_ios/url_launcher_ios.dart'; +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + +import 'url_launcher_ios_test.mocks.dart'; + +// A web URL to use in tests where the specifics of the URL don't matter. +const String _webUrl = 'https://example.com/'; + +@GenerateMocks([UrlLauncherApi]) +void main() { + late MockUrlLauncherApi api; + + setUp(() { + api = MockUrlLauncherApi(); + }); + + test('registers instance', () { + UrlLauncherIOS.registerWith(); + expect(UrlLauncherPlatform.instance, isA()); + }); + + group('canLaunch', () { + test('handles success', () async { + when(api.canLaunchUrl(_webUrl)) + .thenAnswer((_) async => LaunchResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect(await launcher.canLaunch(_webUrl), true); + }); + + test('handles failure', () async { + when(api.canLaunchUrl(_webUrl)) + .thenAnswer((_) async => LaunchResult.failure); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect(await launcher.canLaunch(_webUrl), false); + }); + + test('throws PlatformException for invalid URL', () async { + when(api.canLaunchUrl(_webUrl)) + .thenAnswer((_) async => LaunchResult.invalidUrl); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + await expectLater( + launcher.canLaunch(_webUrl), + throwsA(isA().having( + (PlatformException e) => e.code, 'code', 'argument_error'))); + }); + }); + + group('legacy launch', () { + test('handles success', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.launch( + _webUrl, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, + ), + true); + verifyNever(api.openUrlInSafariViewController(any)); + }); + + test('handles failure', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.failure); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.launch( + _webUrl, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, + ), + false); + verifyNever(api.openUrlInSafariViewController(any)); + }); + + test('throws PlatformException for invalid URL', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.invalidUrl); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + await expectLater( + launcher.launch( + _webUrl, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, + ), + throwsA(isA().having( + (PlatformException e) => e.code, 'code', 'argument_error'))); + }); + + test('force SafariVC is handled', () async { + when(api.openUrlInSafariViewController(_webUrl)) + .thenAnswer((_) async => InAppLoadResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.launch( + _webUrl, + useSafariVC: true, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, + ), + true); + verifyNever(api.launchUrl(any, any)); + }); + + test('universal links only is handled', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.launch( + _webUrl, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: true, + headers: const {}, + ), + true); + verifyNever(api.openUrlInSafariViewController(any)); + }); + + test('disallowing SafariVC is handled', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.launch( + _webUrl, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: const {}, + ), + true); + verifyNever(api.openUrlInSafariViewController(any)); + }); + }); + + test('closeWebView calls through', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + await launcher.closeWebView(); + verify(api.closeSafariViewController()).called(1); + }); + + group('launch without webview', () { + test('calls through', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + final bool launched = await launcher.launchUrl( + _webUrl, + const LaunchOptions(mode: PreferredLaunchMode.externalApplication), + ); + expect(launched, true); + verifyNever(api.openUrlInSafariViewController(any)); + }); + + test('throws PlatformException for invalid URL', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.invalidUrl); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + await expectLater( + launcher.launchUrl( + _webUrl, + const LaunchOptions(mode: PreferredLaunchMode.externalApplication), + ), + throwsA(isA().having( + (PlatformException e) => e.code, 'code', 'argument_error'))); + }); + }); + + group('launch with Safari view controller', () { + test('calls through with inAppWebView', () async { + when(api.openUrlInSafariViewController(_webUrl)) + .thenAnswer((_) async => InAppLoadResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + final bool launched = await launcher.launchUrl( + _webUrl, const LaunchOptions(mode: PreferredLaunchMode.inAppWebView)); + expect(launched, true); + verifyNever(api.launchUrl(any, any)); + }); + + test('calls through with inAppBrowserView', () async { + when(api.openUrlInSafariViewController(_webUrl)) + .thenAnswer((_) async => InAppLoadResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + final bool launched = await launcher.launchUrl(_webUrl, + const LaunchOptions(mode: PreferredLaunchMode.inAppBrowserView)); + expect(launched, true); + verifyNever(api.launchUrl(any, any)); + }); + + test('throws PlatformException for invalid URL', () async { + when(api.openUrlInSafariViewController(_webUrl)) + .thenAnswer((_) async => InAppLoadResult.invalidUrl); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + await expectLater( + launcher.launchUrl(_webUrl, + const LaunchOptions(mode: PreferredLaunchMode.inAppWebView)), + throwsA(isA().having( + (PlatformException e) => e.code, 'code', 'argument_error'))); + }); + + test('throws PlatformException for load failure', () async { + when(api.openUrlInSafariViewController(_webUrl)) + .thenAnswer((_) async => InAppLoadResult.failedToLoad); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + await expectLater( + launcher.launchUrl(_webUrl, + const LaunchOptions(mode: PreferredLaunchMode.inAppWebView)), + throwsA(isA() + .having((PlatformException e) => e.code, 'code', 'Error'))); + }); + }); + + group('launch with universal links', () { + test('calls through', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + final bool launched = await launcher.launchUrl( + _webUrl, + const LaunchOptions( + mode: PreferredLaunchMode.externalNonBrowserApplication), + ); + expect(launched, true); + verifyNever(api.openUrlInSafariViewController(any)); + }); + + test('throws PlatformException for invalid URL', () async { + when(api.launchUrl(_webUrl, any)) + .thenAnswer((_) async => LaunchResult.invalidUrl); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + await expectLater( + launcher.launchUrl( + _webUrl, + const LaunchOptions( + mode: PreferredLaunchMode.externalNonBrowserApplication)), + throwsA(isA().having( + (PlatformException e) => e.code, 'code', 'argument_error'))); + }); + }); + + group('launch with platform default', () { + test('uses Safari view controller for http', () async { + const String httpUrl = 'http://example.com/'; + when(api.openUrlInSafariViewController(httpUrl)) + .thenAnswer((_) async => InAppLoadResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + final bool launched = + await launcher.launchUrl(httpUrl, const LaunchOptions()); + expect(launched, true); + verifyNever(api.launchUrl(any, any)); + }); + + test('uses Safari view controller for https', () async { + const String httpsUrl = 'https://example.com/'; + when(api.openUrlInSafariViewController(httpsUrl)) + .thenAnswer((_) async => InAppLoadResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + final bool launched = + await launcher.launchUrl(httpsUrl, const LaunchOptions()); + expect(launched, true); + verifyNever(api.launchUrl(any, any)); + }); + + test('uses standard external for other schemes', () async { + const String nonWebUrl = 'supportedcustomscheme://example.com/'; + when(api.launchUrl(nonWebUrl, any)) + .thenAnswer((_) async => LaunchResult.success); + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + final bool launched = + await launcher.launchUrl(nonWebUrl, const LaunchOptions()); + expect(launched, true); + verifyNever(api.openUrlInSafariViewController(any)); + }); + }); + + group('supportsMode', () { + test('returns true for platformDefault', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect(await launcher.supportsMode(PreferredLaunchMode.platformDefault), + true); + }); + + test('returns true for external application', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.supportsMode(PreferredLaunchMode.externalApplication), + true); + }); + + test('returns true for external non-browser application', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher + .supportsMode(PreferredLaunchMode.externalNonBrowserApplication), + true); + }); + + test('returns true for in app web view', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.supportsMode(PreferredLaunchMode.inAppWebView), true); + }); + + test('returns true for in app browser view', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect(await launcher.supportsMode(PreferredLaunchMode.inAppBrowserView), + true); + }); + }); + + group('supportsCloseForMode', () { + test('returns true for in app web view', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher.supportsCloseForMode(PreferredLaunchMode.inAppWebView), + true); + }); + + test('returns true for in app browser view', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher + .supportsCloseForMode(PreferredLaunchMode.inAppBrowserView), + true); + }); + + test('returns false for other modes', () async { + final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); + expect( + await launcher + .supportsCloseForMode(PreferredLaunchMode.externalApplication), + false); + expect( + await launcher.supportsCloseForMode( + PreferredLaunchMode.externalNonBrowserApplication), + false); + }); + }); +} diff --git a/test/url_launcher_ios_test.mocks.dart b/test/url_launcher_ios_test.mocks.dart new file mode 100644 index 0000000..ce90785 --- /dev/null +++ b/test/url_launcher_ios_test.mocks.dart @@ -0,0 +1,89 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in url_launcher_ios/test/url_launcher_ios_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; + +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i3; +import 'package:url_launcher_ios/src/messages.g.dart' as _i2; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +/// A class which mocks [UrlLauncherApi]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockUrlLauncherApi extends _i1.Mock implements _i2.UrlLauncherApi { + MockUrlLauncherApi() { + _i1.throwOnMissingStub(this); + } + + @override + String get pigeonVar_messageChannelSuffix => (super.noSuchMethod( + Invocation.getter(#pigeonVar_messageChannelSuffix), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#pigeonVar_messageChannelSuffix), + ), + ) as String); + + @override + _i4.Future<_i2.LaunchResult> canLaunchUrl(String? url) => (super.noSuchMethod( + Invocation.method( + #canLaunchUrl, + [url], + ), + returnValue: + _i4.Future<_i2.LaunchResult>.value(_i2.LaunchResult.success), + ) as _i4.Future<_i2.LaunchResult>); + + @override + _i4.Future<_i2.LaunchResult> launchUrl( + String? url, + bool? universalLinksOnly, + ) => + (super.noSuchMethod( + Invocation.method( + #launchUrl, + [ + url, + universalLinksOnly, + ], + ), + returnValue: + _i4.Future<_i2.LaunchResult>.value(_i2.LaunchResult.success), + ) as _i4.Future<_i2.LaunchResult>); + + @override + _i4.Future<_i2.InAppLoadResult> openUrlInSafariViewController(String? url) => + (super.noSuchMethod( + Invocation.method( + #openUrlInSafariViewController, + [url], + ), + returnValue: + _i4.Future<_i2.InAppLoadResult>.value(_i2.InAppLoadResult.success), + ) as _i4.Future<_i2.InAppLoadResult>); + + @override + _i4.Future closeSafariViewController() => (super.noSuchMethod( + Invocation.method( + #closeSafariViewController, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +}