Bez popisu

WebViewJavascriptBridgeBase.h 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // WebViewJavascriptBridgeBase.h
  3. //
  4. // Created by @LokiMeyburg on 10/15/14.
  5. // Copyright (c) 2014 @LokiMeyburg. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #define kOldProtocolScheme @"wvjbscheme"
  9. #define kNewProtocolScheme @"https"
  10. #define kQueueHasMessage @"__wvjb_queue_message__"
  11. #define kBridgeLoaded @"__bridge_loaded__"
  12. typedef void (^WVJBResponseCallback)(id responseData);
  13. typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);
  14. typedef NSDictionary WVJBMessage;
  15. @protocol WebViewJavascriptBridgeBaseDelegate <NSObject>
  16. - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand;
  17. @end
  18. @interface WebViewJavascriptBridgeBase : NSObject
  19. @property (weak, nonatomic) id <WebViewJavascriptBridgeBaseDelegate> delegate;
  20. @property (strong, nonatomic) NSMutableArray* startupMessageQueue;
  21. @property (strong, nonatomic) NSMutableDictionary* responseCallbacks;
  22. @property (strong, nonatomic) NSMutableDictionary* messageHandlers;
  23. @property (strong, nonatomic) WVJBHandler messageHandler;
  24. + (void)enableLogging;
  25. + (void)setLogMaxLength:(int)length;
  26. - (void)reset;
  27. - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName;
  28. - (void)flushMessageQueue:(NSString *)messageQueueString;
  29. - (void)injectJavascriptFile;
  30. - (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url;
  31. - (BOOL)isQueueMessageURL:(NSURL*)urll;
  32. - (BOOL)isBridgeLoadedURL:(NSURL*)urll;
  33. - (void)logUnkownMessage:(NSURL*)url;
  34. - (NSString *)webViewJavascriptCheckCommand;
  35. - (NSString *)webViewJavascriptFetchQueyCommand;
  36. - (void)disableJavscriptAlertBoxSafetyTimeout;
  37. @end