Nenhuma Descrição

OldWebViewJavascriptBridge.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // WebViewJavascriptBridge.h
  3. // ExampleApp-iOS
  4. //
  5. // Created by Marcus Westin on 6/14/13.
  6. // Copyright (c) 2013 Marcus Westin. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #define kCustomProtocolScheme @"wvjbscheme"
  10. #define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__"
  11. #if defined __MAC_OS_X_VERSION_MAX_ALLOWED
  12. #import <WebKit/WebKit.h>
  13. #define WVJB_PLATFORM_OSX
  14. #define WVJB_WEBVIEW_TYPE WebView
  15. #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
  16. #elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
  17. #import <UIKit/UIWebView.h>
  18. #define WVJB_PLATFORM_IOS
  19. #define WVJB_WEBVIEW_TYPE UIWebView
  20. #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject<UIWebViewDelegate>
  21. #endif
  22. typedef void (^WVJBResponseCallback)(id responseData);
  23. typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);
  24. @interface OldWebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_TYPE
  25. + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler;
  26. + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler;
  27. + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle;
  28. + (void)enableLogging;
  29. - (void)send:(id)message;
  30. - (void)send:(id)message responseCallback:(WVJBResponseCallback)responseCallback;
  31. - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler;
  32. - (void)callHandler:(NSString*)handlerName;
  33. - (void)callHandler:(NSString*)handlerName data:(id)data;
  34. - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
  35. - (void)reset;
  36. @end