admin
2023-04-21 0b3a4aaf99ea251bc8e27b96115288f0988fcffe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
//  DSWKwebview.h
//  dspider
//
//  Created by 杜文 on 16/12/28.
//  Copyright © 2016年 杜文. All rights reserved.
//
 
#import <WebKit/WebKit.h>
 
typedef void (^JSCallback)(NSString * _Nullable result,BOOL complete);
typedef void (^JSCallbackN)(NSNumber * _Nonnull result, BOOL complete);
 
@interface DWKWebView : WKWebView <WKUIDelegate>
 
@property (nullable, nonatomic, weak) id <WKUIDelegate> DSUIDelegate;
 
- (void)loadUrl: (NSString * _Nonnull) url;
 
// Call javascript handler
-(void) callHandler:(NSString * _Nonnull) methodName  arguments:(NSArray * _Nullable) args;
-(void) callHandler:(NSString * _Nonnull) methodName  completionHandler:(void (^ _Nullable)(id _Nullable value))completionHandler;
-(void) callHandler:(NSString * _Nonnull) methodName  arguments:(NSArray * _Nullable) args completionHandler:(void (^ _Nullable)(id _Nullable value))completionHandler;
 
// set a listener for javascript closing the current page.
- (void)setJavascriptCloseWindowListener:(void(^_Nullable)(void))callback;
 
/**
 * Add a Javascript Object to dsBridge with namespace.
 * @param object
 * which implemented the javascript interfaces
 * @param nameSpace
 * if empty, the object have no namespace.
 **/
- (void)addJavascriptObject:(id _Nullable ) object namespace:(NSString *  _Nullable)nameSpace;
 
// Remove the Javascript Object with the supplied namespace
- (void)removeJavascriptObject:(NSString *  _Nullable)nameSpace;
 
// Test whether the handler exist in javascript
- (void) hasJavascriptMethod:(NSString * _Nonnull) handlerName methodExistCallback:(void(^ _Nullable)(bool exist))callback;
 
// Set debug mode. if in debug mode, some errors will be prompted by a dialog
// and the exception caused by the native handlers will not be captured.
- (void) setDebugMode:(bool) debug;
 
- (void) disableJavascriptDialogBlock:(bool) disable;
 
// custom the  label text of  javascript dialog that includes alert/confirm/prompt
- (void) customJavascriptDialogLabelTitles:(NSDictionary*_Nullable) dic;
 
// private method, the developer shoudn't call this method
- (id _Nullable ) onMessage:(NSDictionary *_Nonnull) msg type:(int) type;
 
@end