-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS: add IOS delegate, rect, userAgent and evalJavascript #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your pull request, can you add your name to the authors list and take a look at my comments ?
lib/flutter_webview_plugin.dart
Outdated
_channel.setMethodCallHandler(_handleMessages); | ||
} | ||
|
||
Future<Null> _handleMessages(MethodCall call) async { | ||
print("_handleMessages $call"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove print
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad.
lib/flutter_webview_plugin.dart
Outdated
_init() { | ||
FlutterWebviewPlugin() : | ||
_channel = const MethodChannel(_kChannel), | ||
_event = const EventChannel(_kEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a new channel and not use the existing MethodChannel ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to send event via MethodChannel.
https://github.com/flutter/plugins/blob/master/packages/battery/lib/battery.dart
lib/flutter_webview_plugin.dart
Outdated
final EventChannel _event; | ||
Stream<String> _stateChanged; | ||
|
||
Stream<String> get stateChanged { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onUrlChanged Stream already exist for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a difference could you document it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is difficult to implement onUrlchanged, I will try this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add comment ?
iOS implemented,
Android not implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
NSNumber *clearCache = call.arguments[@"clearCache"]; | ||
NSNumber *clearCookies = call.arguments[@"clearCookies"]; | ||
NSNumber *fullScreen = call.arguments[@"fullScreen"]; | ||
NSNumber *hidden = call.arguments[@"hidden"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you document this ? removing fullscreen
is a breaking change and I need to know if I can do the same thing for Android
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I will add some document.
fullScreen is default.
ios/Classes/FlutterWebviewPlugin.m
Outdated
} | ||
|
||
- (void)initWebView:(FlutterMethodCall*)call { | ||
// NSNumber *withJavascript = call.arguments[@"withJavascript"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, but can we deactivate/activate javascript for iOS webview ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's easy.
@toufikzitouni do you have time to review the iOS part ? |
add eval javascript sink onUrlChanged ...
lib/flutter_webview_plugin.dart
Outdated
/// android: Implemented | ||
/// [fullScreen]: show in full screen mode, default true | ||
/// iOS WebView: without rect, show in full screen mode | ||
/// android: Not implemented yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullscreen is implemented on Android, but hidden is not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
lib/flutter_webview_plugin.dart
Outdated
/// [rect]: show in rect(not full screen) | ||
/// iOS WebView: worked | ||
/// android: Not implemented yet | ||
/// [enableAppScheme]: false will enable all schemes, true only for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS implemented,
Android not implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
lib/flutter_webview_plugin.dart
Outdated
@@ -90,6 +142,10 @@ class FlutterWebviewPlugin { | |||
await _channel.invokeMethod('launch', args); | |||
} | |||
|
|||
Future<String> evalJavascript(String code) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IOS implemented
Android not implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
lib/flutter_webview_plugin.dart
Outdated
_channel = const MethodChannel(_kChannel), | ||
_event = const EventChannel(_kEvent) { | ||
FlutterWebViewPlugin() | ||
: _channel = const MethodChannel(_kChannel), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use on MethodChannel
instead of 2 channels ?
lib/flutter_webview_plugin.dart
Outdated
final EventChannel _event; | ||
Stream<String> _stateChanged; | ||
|
||
Stream<String> get stateChanged { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add comment ?
iOS implemented,
Android not implemented
fix document
android: add rect, fullScreen, userAgent, eval
ios and android more implement
@lejard-h |
Maybe I should close this pull request, and request a new one. |
add UIWebViewDelegate for UIWebView
add rect/hidden argument for the first launch