forked from illusionspaces/WKJavaScriptBridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWKBasePlugin.m
More file actions
62 lines (45 loc) · 1.33 KB
/
WKBasePlugin.m
File metadata and controls
62 lines (45 loc) · 1.33 KB
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
56
57
58
59
60
61
62
//
// WKBasePlugin.m
// Hybrid-framework
//
// Created by Kevin on 2019/4/20.
// Copyright © 2019 王凯. All rights reserved.
//
#import "WKBasePlugin.h"
#import "WKWebViewEngine.h"
@interface WKBasePlugin ()
@property (nonatomic, weak) WKWebViewEngine *webViewEngine;
@end
@implementation WKBasePlugin
- (instancetype)initWithWebViewEngine:(WKWebViewEngine *)webViewEngine {
if (self = [super init]) {
_webViewEngine = webViewEngine;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
}
return self;
}
- (UIViewController *)rootViewController {
if (_webViewEngine != nil) {
if ([self.webViewEngine.webViewDelegate isKindOfClass:[UIViewController class]]) {
return (UIViewController *)self.webViewEngine.webViewDelegate;
}else {
return nil;
}
}
return nil;
}
- (void)pluginInitialize {
}
- (void)onAppTerminate {
}
- (void)onMemoryWarning {
}
- (void)onReset {
}
- (void)dispose {
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end