|
@@ -140,6 +140,15 @@ static NSDictionary* customCertificatesForHost;
|
140
|
140
|
}
|
141
|
141
|
|
142
|
142
|
#if !TARGET_OS_OSX
|
|
143
|
+ [[NSNotificationCenter defaultCenter]addObserver:self
|
|
144
|
+ selector:@selector(appDidBecomeActive)
|
|
145
|
+ name:UIApplicationDidBecomeActiveNotification
|
|
146
|
+ object:nil];
|
|
147
|
+
|
|
148
|
+ [[NSNotificationCenter defaultCenter]addObserver:self
|
|
149
|
+ selector:@selector(appWillResignActive)
|
|
150
|
+ name:UIApplicationWillResignActiveNotification
|
|
151
|
+ object:nil];
|
143
|
152
|
if (@available(iOS 12.0, *)) {
|
144
|
153
|
// Workaround for a keyboard dismissal bug present in iOS 12
|
145
|
154
|
// https://openradar.appspot.com/radar?id=5018321736957952
|
|
@@ -163,6 +172,7 @@ static NSDictionary* customCertificatesForHost;
|
163
|
172
|
selector:@selector(hideFullScreenVideoStatusBars)
|
164
|
173
|
name:UIWindowDidBecomeHiddenNotification
|
165
|
174
|
object:nil];
|
|
175
|
+
|
166
|
176
|
}
|
167
|
177
|
#endif // !TARGET_OS_OSX
|
168
|
178
|
return self;
|
|
@@ -1031,6 +1041,37 @@ static NSDictionary* customCertificatesForHost;
|
1031
|
1041
|
}];
|
1032
|
1042
|
}
|
1033
|
1043
|
|
|
1044
|
+-(void)forceIgnoreSilentHardwareSwitch:(BOOL)initialSetup
|
|
1045
|
+{
|
|
1046
|
+ NSString *mp3Str = @"data:audio/mp3;base64,//tAxAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAAFAAAESAAzMzMzMzMzMzMzMzMzMzMzMzMzZmZmZmZmZmZmZmZmZmZmZmZmZmaZmZmZmZmZmZmZmZmZmZmZmZmZmczMzMzMzMzMzMzMzMzMzMzMzMzM//////////////////////////8AAAA5TEFNRTMuMTAwAZYAAAAAAAAAABQ4JAMGQgAAOAAABEhNIZS0AAAAAAD/+0DEAAPH3Yz0AAR8CPqyIEABp6AxjG/4x/XiInE4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qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==";
|
|
1047
|
+ NSString *scr;
|
|
1048
|
+ if (initialSetup) {
|
|
1049
|
+ scr = [NSString stringWithFormat:@"var s=new Audio('%@');s.id='wkwebviewAudio';s.controls=false;s.loop=true;s.play();document.body.appendChild(s);true", mp3Str];
|
|
1050
|
+ } else {
|
|
1051
|
+ scr = [NSString stringWithFormat:@"var s=document.getElementById('wkwebviewAudio');s.src=null;s.parentNode.removeChild(s);s=null;s=new Audio('%@');s.id='wkwebviewAudio';s.controls=false;s.loop=true;s.play();document.body.appendChild(s);true", mp3Str];
|
|
1052
|
+ }
|
|
1053
|
+ [self evaluateJS: scr thenCall: nil];
|
|
1054
|
+}
|
|
1055
|
+
|
|
1056
|
+-(void)disableIgnoreSilentSwitch
|
|
1057
|
+{
|
|
1058
|
+ [self evaluateJS: @"document.getElementById('wkwebviewAudio').src=null;true" thenCall: nil];
|
|
1059
|
+}
|
|
1060
|
+
|
|
1061
|
+-(void)appDidBecomeActive
|
|
1062
|
+{
|
|
1063
|
+ if (_ignoreSilentHardwareSwitch) {
|
|
1064
|
+ [self forceIgnoreSilentHardwareSwitch:false];
|
|
1065
|
+ }
|
|
1066
|
+}
|
|
1067
|
+
|
|
1068
|
+-(void)appWillResignActive
|
|
1069
|
+{
|
|
1070
|
+ if (_ignoreSilentHardwareSwitch) {
|
|
1071
|
+ [self disableIgnoreSilentSwitch];
|
|
1072
|
+ }
|
|
1073
|
+}
|
|
1074
|
+
|
1034
|
1075
|
/**
|
1035
|
1076
|
* Called when the navigation is complete.
|
1036
|
1077
|
* @see https://fburl.com/rtys6jlb
|
|
@@ -1038,6 +1079,10 @@ static NSDictionary* customCertificatesForHost;
|
1038
|
1079
|
- (void)webView:(WKWebView *)webView
|
1039
|
1080
|
didFinishNavigation:(WKNavigation *)navigation
|
1040
|
1081
|
{
|
|
1082
|
+ if (_ignoreSilentHardwareSwitch) {
|
|
1083
|
+ [self forceIgnoreSilentHardwareSwitch:true];
|
|
1084
|
+ }
|
|
1085
|
+
|
1041
|
1086
|
if (_onLoadingFinish) {
|
1042
|
1087
|
_onLoadingFinish([self baseEvent]);
|
1043
|
1088
|
}
|