+

Inline WebView

flutter logo flutter logo diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 00000000..4882a9e9 --- /dev/null +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/lorenzopichilli/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "OTHER_LDFLAGS=$(inherited) -framework Flutter" +export "FLUTTER_FRAMEWORK_DIR=/Users/lorenzopichilli/flutter/bin/cache/artifacts/engine/ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 4fa3085f..98e6ef55 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -256,13 +256,17 @@ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${PODS_ROOT}/../Flutter/Flutter.framework", "${BUILT_PRODUCTS_DIR}/e2e/e2e.framework", + "${BUILT_PRODUCTS_DIR}/flutter_downloader/flutter_downloader.framework", "${BUILT_PRODUCTS_DIR}/flutter_inappwebview/flutter_inappwebview.framework", + "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/e2e.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_downloader.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_inappwebview.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/example/lib/main.dart b/example/lib/main.dart index 82f75941..1eddcc9f 100755 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,69 +1,21 @@ import 'dart:async'; - +import 'dart:io'; import 'package:flutter/material.dart'; - -import 'package:flutter_inappwebview_example/chrome_safari_browser_example.screen.dart'; -import 'package:flutter_inappwebview_example/headless_in_app_webview.screen.dart'; -import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart'; -import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart'; -// import 'package:permission_handler/permission_handler.dart'; - -// InAppLocalhostServer localhostServer = new InAppLocalhostServer(); +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); -// await Permission.camera.request(); -// await Permission.storage.request(); - // await localhostServer.start(); runApp(MyApp()); } -Drawer myDrawer({@required BuildContext context}) { - return Drawer( - child: ListView( - padding: EdgeInsets.zero, - children: [ - DrawerHeader( - child: Text('flutter_inappbrowser example'), - decoration: BoxDecoration( - color: Colors.blue, - ), - ), - ListTile( - title: Text('InAppBrowser'), - onTap: () { - Navigator.pushReplacementNamed(context, '/InAppBrowser'); - }, - ), - ListTile( - title: Text('ChromeSafariBrowser'), - onTap: () { - Navigator.pushReplacementNamed(context, '/ChromeSafariBrowser'); - }, - ), - ListTile( - title: Text('InAppWebView'), - onTap: () { - Navigator.pushReplacementNamed(context, '/'); - }, - ), - ListTile( - title: Text('HeadlessInAppWebView'), - onTap: () { - Navigator.pushReplacementNamed(context, '/HeadlessInAppWebView'); - }, - ), - ], - ), - ); -} - class MyApp extends StatefulWidget { @override _MyAppState createState() => new _MyAppState(); } class _MyAppState extends State { + InAppWebViewController webView; + CookieManager _cookieManager = CookieManager.instance(); @override void initState() { @@ -78,13 +30,46 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { return MaterialApp( - initialRoute: '/', - routes: { - '/': (context) => InAppWebViewExampleScreen(), - '/InAppBrowser': (context) => InAppBrowserExampleScreen(), - '/ChromeSafariBrowser': (context) => ChromeSafariBrowserExampleScreen(), - '/HeadlessInAppWebView': (context) => HeadlessInAppWebViewExampleScreen(), - } + home: Scaffold( + appBar: AppBar( + title: const Text('InAppWebView Example'), + ), + body: Container( + child: Column(children: [ + Expanded( + child: InAppWebView( + initialUrl: "https://github.com/", + initialOptions: InAppWebViewGroupOptions( + crossPlatform: InAppWebViewOptions( + debuggingEnabled: true + ), + ), + onWebViewCreated: (InAppWebViewController controller) { + webView = controller; + }, + onLoadStart: (InAppWebViewController controller, String url) {}, + onLoadStop: (InAppWebViewController controller, String url) async { + + }, + )), + Expanded( + child: InAppWebView( + initialUrl: "https://github.com/", + initialOptions: InAppWebViewGroupOptions( + crossPlatform: InAppWebViewOptions( + debuggingEnabled: true + ), + ), + onWebViewCreated: (InAppWebViewController controller) { + webView = controller; + }, + onLoadStart: (InAppWebViewController controller, String url) {}, + onLoadStop: (InAppWebViewController controller, String url) async { + + }, + )) + ])), + ), ); } -} \ No newline at end of file +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 948f10cf..c4375f72 100755 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -20,9 +20,10 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 - # flutter_downloader: ^1.3.2 - # path_provider: ^1.4.0 + flutter_downloader: ^1.4.4 + path_provider: ^1.6.9 permission_handler: ^5.0.0+hotfix.6 + # webview_flutter: ^0.3.22+1 # connectivity: ^0.4.5+6 flutter_inappwebview: path: ../ diff --git a/ios/Classes/InAppWebView.swift b/ios/Classes/InAppWebView.swift index e9beed31..c6463b6f 100755 --- a/ios/Classes/InAppWebView.swift +++ b/ios/Classes/InAppWebView.swift @@ -1037,28 +1037,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi configuration.userContentController.addUserScript(interceptFetchRequestsJSScript) } - if #available(iOS 9.0, *) { - if ((options?.incognito)!) { - configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent() - } else if ((options?.cacheEnabled)!) { - configuration.websiteDataStore = WKWebsiteDataStore.default() - } - } - if #available(iOS 11.0, *) { - if((options?.sharedCookiesEnabled)!) { - // More info to sending cookies with WKWebView - // https://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview/26577303#26577303 - // Set Cookies in iOS 11 and above, initialize websiteDataStore before setting cookies - // See also https://forums.developer.apple.com/thread/97194 - // check if websiteDataStore has not been initialized before - if(!(options?.incognito)! && !(options?.cacheEnabled)!) { - configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent() - } - for cookie in HTTPCookieStorage.shared.cookies ?? [] { - configuration.websiteDataStore.httpCookieStore.setCookie(cookie, completionHandler: nil) - } - } accessibilityIgnoresInvertColors = (options?.accessibilityIgnoresInvertColors)! } @@ -1229,6 +1208,30 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi } } + if #available(iOS 9.0, *) { + if ((options?.incognito)!) { + configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent() + } else if ((options?.cacheEnabled)!) { + configuration.websiteDataStore = WKWebsiteDataStore.default() + } + } + + if #available(iOS 11.0, *) { + if((options?.sharedCookiesEnabled)!) { + // More info to sending cookies with WKWebView + // https://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview/26577303#26577303 + // Set Cookies in iOS 11 and above, initialize websiteDataStore before setting cookies + // See also https://forums.developer.apple.com/thread/97194 + // check if websiteDataStore has not been initialized before + if(!(options?.incognito)! && !(options?.cacheEnabled)!) { + configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent() + } + for cookie in HTTPCookieStorage.shared.cookies ?? [] { + configuration.websiteDataStore.httpCookieStore.setCookie(cookie, completionHandler: nil) + } + } + } + return configuration } diff --git a/ios/flutter_inappwebview.podspec b/ios/flutter_inappwebview.podspec index ce183555..6e004a6b 100755 --- a/ios/flutter_inappwebview.podspec +++ b/ios/flutter_inappwebview.podspec @@ -1,5 +1,6 @@ # -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint flutterplugintest.podspec' to validate before publishing. # Pod::Spec.new do |s| s.name = 'flutter_inappwebview' @@ -16,7 +17,9 @@ A new Flutter plugin. s.resources = 'Storyboards/**/*.storyboard' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - + s.platform = :ios, '8.0' + + # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } s.swift_version = '5.0' end diff --git a/lib/src/in_app_webview_controller.dart b/lib/src/in_app_webview_controller.dart index ed962060..10b3a436 100644 --- a/lib/src/in_app_webview_controller.dart +++ b/lib/src/in_app_webview_controller.dart @@ -1597,7 +1597,7 @@ class AndroidInAppWebViewController { return await _controller._channel.invokeMethod('pageUp', args); } - ///Saves the current view as a web archive. + ///Saves the current WebView as a web archive. ///Returns the filename under which the file was saved, or `null` if saving the file failed. /// ///[basename] the filename where the archive should be placed. This value cannot be `null`. diff --git a/pubspec.yaml b/pubspec.yaml index 32c4a798..2840ded7 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 3.3.0 +version: 3.3.0+3 homepage: https://github.com/pichillilorenzo/flutter_inappwebview environment: