Skip to content

WKWebView Support #105

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

Merged
merged 22 commits into from
Jul 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f39324d
Added the WKWebViewJavascriptBridge class
lokimeyburg Oct 14, 2014
b535dc2
Updated the example app to use WKWebView
lokimeyburg Oct 15, 2014
84bbefc
Improved startup message queue for WKWebView
lokimeyburg Oct 15, 2014
026a712
Example app dynamically includes Webkit if iOS 8
lokimeyburg Oct 15, 2014
b458d79
Added compiler flags to include Yosemite
lokimeyburg Oct 15, 2014
553cf74
Added README documentation on using WKWebview
lokimeyburg Oct 15, 2014
99627d8
Added examples on using WKWebView to the README
lokimeyburg Oct 15, 2014
95779d0
Removed unnecessary NSLog output
lokimeyburg Oct 27, 2014
859c823
Added JavascriptWebViewBridgeBase to WKWebViewJavascriptBridge
lokimeyburg Oct 30, 2014
b318263
WKWebViewJavascriptBridge successfully using Base class with delegate…
lokimeyburg Nov 8, 2014
589dc2a
Using Base class in UIWebView
lokimeyburg Nov 8, 2014
7382589
You can toggle between UIWebView and WKWebView in the example app
lokimeyburg Nov 8, 2014
e2bdcf5
Both examples working without any immediate bugs
lokimeyburg Nov 9, 2014
1bce38a
Updated OSX WebView to use the new Base class
lokimeyburg Nov 9, 2014
4e990fb
Removed compiler warnings
lokimeyburg Nov 9, 2014
59d4f19
Using proper class names for example view controllers
lokimeyburg Nov 9, 2014
a7c4a03
WKWebView example only available on iOS 8 devices
lokimeyburg Nov 9, 2014
c376eb5
Fixed compiler error for pointer mismatch
lokimeyburg Dec 3, 2014
18820b7
wkwebview example for osx
lokimeyburg Dec 4, 2014
c74cf3d
Added OSX example. Still running into z-index issues with WKWebView
lokimeyburg Dec 5, 2014
bd73d7c
Fixed OSX Example
lokimeyburg Dec 8, 2014
35a8b7b
Updated README to include warning about WKWebview network API support
lokimeyburg Dec 8, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
0ECB01491A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB01461A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m */; };
0ECB014A1A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB01481A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m */; };
2C136A2517641106004C7401 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C136A2417641106004C7401 /* Cocoa.framework */; };
2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A2D17641106004C7401 /* InfoPlist.strings */; };
2C136A3117641106004C7401 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A3017641106004C7401 /* main.m */; };
Expand All @@ -20,6 +22,10 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
0ECB01451A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = "<group>"; };
0ECB01461A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = "<group>"; };
0ECB01471A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = "<group>"; };
0ECB01481A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = "<group>"; };
2C136A2117641106004C7401 /* ExampleApp-OSX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ExampleApp-OSX.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2C136A2417641106004C7401 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
2C136A2717641106004C7401 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -118,6 +124,10 @@
2C1562C1176BA9FF00B4AE50 /* WebViewJavascriptBridge */ = {
isa = PBXGroup;
children = (
0ECB01451A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.h */,
0ECB01461A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m */,
0ECB01471A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.h */,
0ECB01481A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m */,
2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */,
2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */,
2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */,
Expand Down Expand Up @@ -192,6 +202,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0ECB01491A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m in Sources */,
0ECB014A1A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m in Sources */,
2C136A3117641106004C7401 /* main.m in Sources */,
2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */,
2C136A3817641106004C7401 /* AppDelegate.m in Sources */,
Expand Down
113 changes: 98 additions & 15 deletions Example Apps/ExampleApp-OSX/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@
#import "AppDelegate.h"
#import <WebKit/WebKit.h>
#import "WebViewJavascriptBridge.h"
#import "WKWebViewJavascriptBridge.h"

@implementation AppDelegate {
WebView* _webView;
WKWebView *_WKWebView;
WebViewJavascriptBridge* _bridge;
WKWebViewJavascriptBridge* _WKBridge;
NSView* _WKWebViewWrapper;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self _createViews];
[self _createBridge];
[self _createObjcButtons];
[self _loadPage];
[self _configureWebview];
[self _configureWKWebview];
}

- (void)_createBridge {
- (void)_configureWebview {
// Create Bridge
_bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:^(id data, WVJBResponseCallback responseCallback) {
NSLog(@"ObjC received message from JS: %@", data);
responseCallback(@"Response for message from ObjC");
Expand All @@ -39,22 +43,86 @@ - (void)_createBridge {
}];

[_bridge callHandler:@"testJavascriptHandler" data:@{ @"foo":@"before ready" }];
}

- (void)_createObjcButtons {
// Create Buttons
NSButton *messageButton = [[NSButton alloc] initWithFrame:NSMakeRect(5, 0, 120, 40)];
[messageButton setTitle:@"Send message"];
[messageButton setBezelStyle:NSRoundedBezelStyle];
[messageButton setTarget:self];
[messageButton setAction:@selector(_sendMessage)];
[_webView addSubview:messageButton];

[_webView addSubview:messageButton];
NSButton *callbackButton = [[NSButton alloc] initWithFrame:NSMakeRect(120, 0, 120, 40)];
[callbackButton setTitle:@"Call handler"];
[callbackButton setBezelStyle:NSRoundedBezelStyle];
[callbackButton setTarget:self];
[callbackButton setAction:@selector(_callHandler)];
[_webView addSubview:callbackButton];

NSButton *webViewToggleButton = [[NSButton alloc] initWithFrame:NSMakeRect(235, 0, 180, 40)];
[webViewToggleButton setTitle:@"Switch to WKWebView"];
[webViewToggleButton setBezelStyle:NSRoundedBezelStyle];
[webViewToggleButton setTarget:self];
[webViewToggleButton setAction:@selector(_toggleExample)];
[_webView addSubview:webViewToggleButton];


// Load Page
NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"];
NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
[[_webView mainFrame] loadHTMLString:html baseURL:nil];
}


- (void)_configureWKWebview {
// Create Bridge
_WKBridge = [WKWebViewJavascriptBridge bridgeForWebView:_WKWebView handler:^(id data, WVJBResponseCallback responseCallback) {
NSLog(@"ObjC received message from JS: %@", data);
responseCallback(@"Response for message from ObjC");
}];

[_WKBridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) {
NSLog(@"testObjcCallback called: %@", data);
responseCallback(@"Response from testObjcCallback");
}];

[_WKBridge send:@"A string sent from ObjC before Webview has loaded." responseCallback:^(id responseData) {
NSLog(@"objc got response! %@", responseData);
}];

[_WKBridge callHandler:@"testJavascriptHandler" data:@{ @"foo":@"before ready" }];

// Create Buttons
NSButton *messageButton = [[NSButton alloc] initWithFrame:NSMakeRect(5, 0, 120, 40)];
[messageButton setTitle:@"Send message"];
[messageButton setBezelStyle:NSRoundedBezelStyle];
[messageButton setTarget:self];
[messageButton setAction:@selector(_WKSendMessage)];
[_WKWebView addSubview:messageButton];

NSButton *callbackButton = [[NSButton alloc] initWithFrame:NSMakeRect(120, 0, 120, 40)];
[callbackButton setTitle:@"Call handler"];
[callbackButton setBezelStyle:NSRoundedBezelStyle];
[callbackButton setTarget:self];
[callbackButton setAction:@selector(_WKCallHandler)];
[_WKWebView addSubview:callbackButton];

NSButton *webViewToggleButton = [[NSButton alloc] initWithFrame:NSMakeRect(235, 0, 180, 40)];
[webViewToggleButton setTitle:@"Switch to WebView"];
[webViewToggleButton setBezelStyle:NSRoundedBezelStyle];
[webViewToggleButton setTarget:self];
[webViewToggleButton setAction:@selector(_toggleExample)];
[_WKWebView addSubview:webViewToggleButton];

// Load Page
NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"];
NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
[_WKWebView loadHTMLString:html baseURL:nil];
}

-(void)_toggleExample {
_WKWebView.hidden = !_WKWebView.isHidden;
_webView.hidden = !_webView.isHidden;
}

- (void)_sendMessage {
Expand All @@ -67,21 +135,36 @@ - (void)_callHandler {
id data = @{ @"greetingFromObjC": @"Hi there, JS!" };
[_bridge callHandler:@"testJavascriptHandler" data:data responseCallback:^(id response) {
NSLog(@"testJavascriptHandler responded: %@", response);
}];
}];
}

- (void)_WKSendMessage {
[_WKBridge send:@"A string sent from ObjC to JS" responseCallback:^(id response) {
NSLog(@"sendMessage got response: %@", response);
}];
}

- (void)_WKCallHandler {
id data = @{ @"greetingFromObjC": @"Hi there, JS!" };
[_WKBridge callHandler:@"testJavascriptHandler" data:data responseCallback:^(id response) {
NSLog(@"testJavascriptHandler responded: %@", response);
}];
}

- (void)_createViews {
NSView* contentView = _window.contentView;
// WebView
_webView = [[WebView alloc] initWithFrame:contentView.frame];
[_webView setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)];
_webView.hidden = YES;

// WKWebView
_WKWebView = [[WKWebView alloc] initWithFrame:contentView.frame];
[_WKWebView setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)];

[contentView addSubview:_WKWebView];
[contentView addSubview:_webView];
}

- (void)_loadPage {
NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"];
NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
[[_webView mainFrame] loadHTMLString:html baseURL:nil];
}


@end
2 changes: 1 addition & 1 deletion Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>WebViewJavascriptBridge.${PRODUCT_NAME:rfc1034identifier}</string>
<string>WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
36 changes: 30 additions & 6 deletions Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
objects = {

/* Begin PBXBuildFile section */
0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E8082DC19EDD98700479452 /* WebKit.framework */; };
0E50601C1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E50601B1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m */; };
0E8082DB19EDC32300479452 /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E8082DA19EDC32300479452 /* WKWebViewJavascriptBridge.m */; };
0ECB01441A0EE1F20037FF4E /* ExampleWKWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */; };
2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */; };
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */; };
2C45CA2C1884AD520002A4E2 /* ExampleAppViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C45CA2B1884AD520002A4E2 /* ExampleAppViewController.m */; };
2C45CA2C1884AD520002A4E2 /* ExampleUIWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */; };
2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2CA045B717117439006DEE8B /* InfoPlist.strings */; };
2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */; };
2CA045C317117439006DEE8B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BE17117439006DEE8B /* main.m */; };
Expand All @@ -21,11 +25,18 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
0E50601B1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = "<group>"; };
0E50601D1A01B44C000BEEEA /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = "<group>"; };
0E8082D919EDC32300479452 /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = "<group>"; };
0E8082DA19EDC32300479452 /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = "<group>"; };
0E8082DC19EDD98700479452 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
0ECB01421A0EE1BA0037FF4E /* ExampleWKWebViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExampleWKWebViewController.h; sourceTree = "<group>"; };
0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleWKWebViewController.m; sourceTree = "<group>"; };
2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = "<group>"; };
2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = "<group>"; };
2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
2C45CA2A1884AD520002A4E2 /* ExampleAppViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleAppViewController.h; sourceTree = "<group>"; };
2C45CA2B1884AD520002A4E2 /* ExampleAppViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleAppViewController.m; sourceTree = "<group>"; };
2C45CA2A1884AD520002A4E2 /* ExampleUIWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleUIWebViewController.h; sourceTree = "<group>"; };
2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleUIWebViewController.m; sourceTree = "<group>"; };
2CA045B817117439006DEE8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2CA045B917117439006DEE8B /* ExampleApp-iOS-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ExampleApp-iOS-Info.plist"; sourceTree = "<group>"; };
2CA045BA17117439006DEE8B /* ExampleApp-iOS-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ExampleApp-iOS-Prefix.pch"; sourceTree = "<group>"; };
Expand All @@ -45,6 +56,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */,
2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */,
2CEB3EC21602563600548120 /* Foundation.framework in Frameworks */,
2CEB3EC41602563600548120 /* CoreGraphics.framework in Frameworks */,
Expand All @@ -60,6 +72,10 @@
2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */,
2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */,
2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */,
0E8082DA19EDC32300479452 /* WKWebViewJavascriptBridge.m */,
0E8082D919EDC32300479452 /* WKWebViewJavascriptBridge.h */,
0E50601B1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m */,
0E50601D1A01B44C000BEEEA /* WebViewJavascriptBridgeBase.h */,
);
name = WebViewJavascriptBridge;
path = ../../WebViewJavascriptBridge;
Expand All @@ -71,8 +87,10 @@
2CA0465B1711AC8D006DEE8B /* ExampleApp.html */,
2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */,
2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */,
2C45CA2A1884AD520002A4E2 /* ExampleAppViewController.h */,
2C45CA2B1884AD520002A4E2 /* ExampleAppViewController.m */,
2C45CA2A1884AD520002A4E2 /* ExampleUIWebViewController.h */,
2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */,
0ECB01421A0EE1BA0037FF4E /* ExampleWKWebViewController.h */,
0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */,
2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */,
2CA046211711A94E006DEE8B /* Supporting Files */,
);
Expand Down Expand Up @@ -111,6 +129,7 @@
2CEB3EBE1602563600548120 /* Frameworks */ = {
isa = PBXGroup;
children = (
0E8082DC19EDD98700479452 /* WebKit.framework */,
2CEB3EBF1602563600548120 /* UIKit.framework */,
2CEB3EC11602563600548120 /* Foundation.framework */,
2CEB3EC31602563600548120 /* CoreGraphics.framework */,
Expand Down Expand Up @@ -184,8 +203,11 @@
buildActionMask = 2147483647;
files = (
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */,
2C45CA2C1884AD520002A4E2 /* ExampleAppViewController.m in Sources */,
0E8082DB19EDC32300479452 /* WKWebViewJavascriptBridge.m in Sources */,
2C45CA2C1884AD520002A4E2 /* ExampleUIWebViewController.m in Sources */,
0ECB01441A0EE1F20037FF4E /* ExampleWKWebViewController.m in Sources */,
2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */,
0E50601C1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m in Sources */,
2CA045C317117439006DEE8B /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -258,6 +280,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleApp-iOS/ExampleApp-iOS-Prefix.pch";
INFOPLIST_FILE = "ExampleApp-iOS/ExampleApp-iOS-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
PRODUCT_NAME = "ExampleApp-iOS";
WRAPPER_EXTENSION = app;
};
Expand All @@ -269,6 +292,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleApp-iOS/ExampleApp-iOS-Prefix.pch";
INFOPLIST_FILE = "ExampleApp-iOS/ExampleApp-iOS-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
PRODUCT_NAME = "ExampleApp-iOS";
WRAPPER_EXTENSION = app;
};
Expand Down
21 changes: 19 additions & 2 deletions Example Apps/ExampleApp-iOS/ExampleAppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#import "ExampleAppDelegate.h"
#import "ExampleAppViewController.h"
#import "ExampleUIWebViewController.h"
#import "ExampleWKWebViewController.h"

@implementation ExampleAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// 1. Create the UIWebView example
ExampleUIWebViewController* UIWebViewExampleController = [[ExampleUIWebViewController alloc] init];
UIWebViewExampleController.tabBarItem.title = @"UIWebView";

// 2. Create the tab footer and add the UIWebView example
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController addChildViewController:UIWebViewExampleController];

// 3. Create the WKWebView example for devices >= iOS 8
if([WKWebView class]) {
ExampleWKWebViewController* WKWebViewExampleController = [[ExampleWKWebViewController alloc] init];
WKWebViewExampleController.tabBarItem.title = @"WKWebView";
[tabBarController addChildViewController:WKWebViewExampleController];
}

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [ExampleAppViewController new];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
Expand Down
Loading