Skip to content

Commit

Permalink
Simplify setup and file organization by doing away with the Abstract/…
Browse files Browse the repository at this point in the history
…iOS/OSX seperation. Instead, we manage the iOS/OSX platform specific part using macros
  • Loading branch information
marcuswestin committed Jun 14, 2013
1 parent baf4a06 commit 57ee322
Show file tree
Hide file tree
Showing 17 changed files with 468 additions and 515 deletions.
42 changes: 14 additions & 28 deletions Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
2C136A3517641106004C7401 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A3317641106004C7401 /* Credits.rtf */; };
2C136A3817641106004C7401 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A3717641106004C7401 /* AppDelegate.m */; };
2C136A4217641236004C7401 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C136A4117641236004C7401 /* WebKit.framework */; };
2C136A5617642680004C7401 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A5117642680004C7401 /* WebViewJavascriptBridge.js.txt */; };
2C136A5717642680004C7401 /* WebViewJavascriptBridgeAbstract.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A5317642680004C7401 /* WebViewJavascriptBridgeAbstract.m */; };
2C136A5817642680004C7401 /* WebViewJavascriptBridge_OSX.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A5517642680004C7401 /* WebViewJavascriptBridge_OSX.m */; };
2C136A5A17642704004C7401 /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A5917642704004C7401 /* ExampleApp.html */; };
2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */; };
2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -33,12 +32,10 @@
2C136A3617641106004C7401 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
2C136A3717641106004C7401 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
2C136A4117641236004C7401 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
2C136A5117642680004C7401 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
2C136A5217642680004C7401 /* WebViewJavascriptBridgeAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeAbstract.h; sourceTree = "<group>"; };
2C136A5317642680004C7401 /* WebViewJavascriptBridgeAbstract.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeAbstract.m; sourceTree = "<group>"; };
2C136A5417642680004C7401 /* WebViewJavascriptBridge_OSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_OSX.h; sourceTree = "<group>"; };
2C136A5517642680004C7401 /* WebViewJavascriptBridge_OSX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_OSX.m; sourceTree = "<group>"; };
2C136A5917642704004C7401 /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; };
2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = "<group>"; };
2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -97,7 +94,7 @@
2C136A3617641106004C7401 /* AppDelegate.h */,
2C136A3717641106004C7401 /* AppDelegate.m */,
2C136A5917642704004C7401 /* ExampleApp.html */,
2C136A4F17642680004C7401 /* WebViewJavascriptBridge_OSX */,
2C1562C1176BA9FF00B4AE50 /* WebViewJavascriptBridge */,
2C136A2B17641106004C7401 /* Supporting Files */,
);
path = "ExampleApp-OSX";
Expand All @@ -115,25 +112,15 @@
name = "Supporting Files";
sourceTree = "<group>";
};
2C136A4F17642680004C7401 /* WebViewJavascriptBridge_OSX */ = {
2C1562C1176BA9FF00B4AE50 /* WebViewJavascriptBridge */ = {
isa = PBXGroup;
children = (
2C136A5017642680004C7401 /* WebViewJavascriptAbstract */,
2C136A5417642680004C7401 /* WebViewJavascriptBridge_OSX.h */,
2C136A5517642680004C7401 /* WebViewJavascriptBridge_OSX.m */,
2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */,
2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */,
2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */,
);
name = WebViewJavascriptBridge_OSX;
path = ../../WebViewJavascriptBridge_OSX;
sourceTree = "<group>";
};
2C136A5017642680004C7401 /* WebViewJavascriptAbstract */ = {
isa = PBXGroup;
children = (
2C136A5117642680004C7401 /* WebViewJavascriptBridge.js.txt */,
2C136A5217642680004C7401 /* WebViewJavascriptBridgeAbstract.h */,
2C136A5317642680004C7401 /* WebViewJavascriptBridgeAbstract.m */,
);
path = WebViewJavascriptAbstract;
name = WebViewJavascriptBridge;
path = ../../WebViewJavascriptBridge;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -187,9 +174,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */,
2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */,
2C136A3517641106004C7401 /* Credits.rtf in Resources */,
2C136A5617642680004C7401 /* WebViewJavascriptBridge.js.txt in Resources */,
2C136A5A17642704004C7401 /* ExampleApp.html in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -202,9 +189,8 @@
buildActionMask = 2147483647;
files = (
2C136A3117641106004C7401 /* main.m in Sources */,
2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */,
2C136A3817641106004C7401 /* AppDelegate.m in Sources */,
2C136A5717642680004C7401 /* WebViewJavascriptBridgeAbstract.m in Sources */,
2C136A5817642680004C7401 /* WebViewJavascriptBridge_OSX.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion Example Apps/ExampleApp-OSX/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "AppDelegate.h"
#import <WebKit/WebKit.h>
#import "WebViewJavascriptBridge_OSX.h"
#import "WebViewJavascriptBridge.h"

@implementation AppDelegate {
WebView* _webView;
Expand Down
52 changes: 19 additions & 33 deletions Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,29 @@
objects = {

/* Begin PBXBuildFile section */
2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */; };
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.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 */; };
2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */; };
2CAB868B172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB8686172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt */; };
2CAB868C172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CAB8688172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m */; };
2CAB868D172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CAB868A172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m */; };
2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */; };
2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EBF1602563600548120 /* UIKit.framework */; };
2CEB3EC21602563600548120 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC11602563600548120 /* Foundation.framework */; };
2CEB3EC41602563600548120 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC31602563600548120 /* CoreGraphics.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
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>"; };
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>"; };
2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleAppDelegate.h; sourceTree = "<group>"; };
2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleAppDelegate.m; sourceTree = "<group>"; };
2CA045BE17117439006DEE8B /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
2CA0465B1711AC8D006DEE8B /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; };
2CAB8686172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = "<group>"; };
2CAB8687172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeAbstract.h; sourceTree = "<group>"; };
2CAB8688172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeAbstract.m; sourceTree = "<group>"; };
2CAB8689172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_iOS.h; sourceTree = "<group>"; };
2CAB868A172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_iOS.m; sourceTree = "<group>"; };
2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "ExampleApp-iOS/Default-568h@2x.png"; sourceTree = "<group>"; };
2CEB3EBB1602563600548120 /* ExampleApp-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ExampleApp-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2CEB3EBF1602563600548120 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
Expand All @@ -54,13 +51,24 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */ = {
isa = PBXGroup;
children = (
2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */,
2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */,
2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */,
);
name = WebViewJavascriptBridge;
path = ../../WebViewJavascriptBridge;
sourceTree = "<group>";
};
2CA045B617117439006DEE8B /* ExampleApp-iOS */ = {
isa = PBXGroup;
children = (
2CA0465B1711AC8D006DEE8B /* ExampleApp.html */,
2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */,
2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */,
2CAB8684172766B000BD9ED1 /* WebViewJavascriptBridge_iOS */,
2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */,
2CA046211711A94E006DEE8B /* Supporting Files */,
);
path = "ExampleApp-iOS";
Expand All @@ -77,27 +85,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
2CAB8684172766B000BD9ED1 /* WebViewJavascriptBridge_iOS */ = {
isa = PBXGroup;
children = (
2CAB8685172766B000BD9ED1 /* WebViewJavascriptAbstract */,
2CAB8689172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.h */,
2CAB868A172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m */,
);
name = WebViewJavascriptBridge_iOS;
path = ../../WebViewJavascriptBridge_iOS;
sourceTree = "<group>";
};
2CAB8685172766B000BD9ED1 /* WebViewJavascriptAbstract */ = {
isa = PBXGroup;
children = (
2CAB8686172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt */,
2CAB8687172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.h */,
2CAB8688172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m */,
);
path = WebViewJavascriptAbstract;
sourceTree = "<group>";
};
2CEB3EB01602563600548120 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -177,9 +164,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */,
2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */,
2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */,
2CAB868B172766B000BD9ED1 /* WebViewJavascriptBridge.js.txt in Resources */,
2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -191,10 +178,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */,
2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */,
2CA045C317117439006DEE8B /* main.m in Sources */,
2CAB868C172766B000BD9ED1 /* WebViewJavascriptBridgeAbstract.m in Sources */,
2CAB868D172766B000BD9ED1 /* WebViewJavascriptBridge_iOS.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion Example Apps/ExampleApp-iOS/ExampleAppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import <UIKit/UIKit.h>
#import "WebViewJavascriptBridge_iOS.h"
#import "WebViewJavascriptBridge.h"

@interface ExampleAppDelegate : UIResponder <UIApplicationDelegate>

Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ Start with the Example Apps/ folder. Open either the iOS or OSX project and hit

To use a WebViewJavascriptBridge in your own project:

1) Drag the `WebViewJavascriptBridge_iOS` or `WebViewJavascriptBridge_OSX` folder into your project.
1) Drag the `WebViewJavascriptBridge` folder into your project.

- In the dialog that appears, uncheck "Copy items into destination group's folder" and select "Create groups for any folders"

2) Import the header file:

// for iOS:
#import "WebViewJavascriptBridge_iOS.h"
// for OSX:
#import "WebViewJavascriptBridge_OSX.h"
#import "WebViewJavascriptBridge.h"

3) Instantiate WebViewJavascriptBridge with a UIWebView (iOS) or WebView (OSX):

Expand Down
4 changes: 2 additions & 2 deletions WebViewJavascriptBridge.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/marcuswestin/WebViewJavascriptBridge.git' }
s.ios.platform = :ios, '5.0'
s.osx.platform = :osx
s.ios.source_files = 'WebViewJavascriptBridge_iOS/*.{h,m}', 'WebViewJavascriptBridgeAbstract/*.{h,m}'
s.osx.source_files = 'WebViewJavascriptBridge_OSX/*.{h,m}', 'WebViewJavascriptBridgeAbstract/*.{h,m}'
s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}'
s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}'
s.resource = 'WebViewJavascriptBridgeAbstract/WebViewJavascriptBridge.js.txt'
s.ios.framework = 'UIKit'
s.osx.framework = 'WebKit'
Expand Down
51 changes: 51 additions & 0 deletions WebViewJavascriptBridge/WebViewJavascriptBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// WebViewJavascriptBridge.h
// ExampleApp-iOS
//
// Created by Marcus Westin on 6/14/13.
// Copyright (c) 2013 Marcus Westin. All rights reserved.
//

#import <Foundation/Foundation.h>

#define kMessageSeparator @"__WVJB_MESSAGE_SEPERATOR__"
#define kCustomProtocolScheme @"wvjbscheme"
#define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__"

#if TARGET_OS_IPHONE && defined(__IPHONE_5_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0)
#define WVJB_WEAK_FALLBACK weak
#elif TARGET_OS_MAC && defined(__MAC_10_7) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7)
#define WVJB_WEAK_FALLBACK weak
#else
#define WVJB_WEAK_FALLBACK unsafe_unretained
#endif

#if defined __MAC_OS_X_VERSION_MAX_ALLOWED
#import <WebKit/WebKit.h>
#define WVJB_PLATFORM_OSX
#define WVJB_WEBVIEW_TYPE WebView
#define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
#elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
#define WVJB_PLATFORM_IOS
#define WVJB_WEBVIEW_TYPE UIWebView
#define WVJB_WEBVIEW_DELEGATE_TYPE NSObject<UIWebViewDelegate>
#endif

typedef void (^WVJBResponseCallback)(id responseData);
typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);

@interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_TYPE

+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler;
+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler;
+ (void)enableLogging;

- (void)send:(id)message;
- (void)send:(id)message responseCallback:(WVJBResponseCallback)responseCallback;
- (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler;
- (void)callHandler:(NSString*)handlerName;
- (void)callHandler:(NSString*)handlerName data:(id)data;
- (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
- (void)reset;

@end
Loading

0 comments on commit 57ee322

Please sign in to comment.