Skip to content

Commit 6273572

Browse files
jcesarmobilemlynch
authored andcommitted
Remove WKSuspendInBackground preference (#310)
* Remove WKSuspendInBackground preference * Update README.md
1 parent 03c5799 commit 6273572

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ If `UseScheme` is set to yes, it will use the `HostName` value as the host of th
7878

7979
Example `ionic://app`
8080

81-
#### WKSuspendInBackground
81+
#### WKSuspendInBackground (Removed in 2.4.0)
82+
83+
This preference has been removed in 2.4.0 version of the plugin as it relied on a private API. Apps relying on this preference will not work as intended after the update. It will act as the previous default value, which was true.
8284

8385
```xml
84-
<preference name="WKSuspendInBackground" value="false" />
86+
<preference name="WKSuspendInBackground" value="true" />
8587
```
8688

8789
Whether to try to keep the server running when the app is backgrounded. Note: the server will likely be suspended by the OS after a few minutes. In particular, long-lived background tasks are not allowed on iOS outside of select audio and geolocation tasks.

src/ios/CDVWKWebViewEngine.m

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ @interface CDVWKWebViewEngine ()
117117
// expose private configuration value required for background operation
118118
@interface WKWebViewConfiguration ()
119119

120-
@property (setter=_setAlwaysRunsAtForegroundPriority:, nonatomic) bool _alwaysRunsAtForegroundPriority;
121-
122120
@end
123121

124122

@@ -221,15 +219,9 @@ -(void)startServer
221219
int portNumber = [settings cordovaFloatSettingForKey:@"WKPort" defaultValue:8080];
222220

223221
//enable suspend in background if set in config
224-
BOOL suspendInBackground = [settings cordovaBoolSettingForKey:@"WKSuspendInBackground" defaultValue:YES];
222+
BOOL suspendInBackground = YES;
225223
int waitTime = 10;
226224

227-
//extend default connection coalescing time when background enabled
228-
if(!suspendInBackground){
229-
NSLog(@"CDVWKWebViewEngine: Suspend in background disabled");
230-
waitTime = 60;
231-
}
232-
233225
NSDictionary *options = @{
234226
GCDWebServerOption_AutomaticallySuspendInBackground: @(suspendInBackground),
235227
GCDWebServerOption_ConnectedStateCoalescingInterval: @(waitTime),
@@ -259,8 +251,6 @@ - (WKWebViewConfiguration*) createConfigurationFromSettings:(NSDictionary*)setti
259251
return configuration;
260252
}
261253

262-
//required to stop wkwebview suspending in background too eagerly (as used in background mode plugin)
263-
configuration._alwaysRunsAtForegroundPriority = ![settings cordovaBoolSettingForKey:@"WKSuspendInBackground" defaultValue:YES];
264254
configuration.allowsInlineMediaPlayback = [settings cordovaBoolSettingForKey:@"AllowInlineMediaPlayback" defaultValue:YES];
265255
configuration.suppressesIncrementalRendering = [settings cordovaBoolSettingForKey:@"SuppressesIncrementalRendering" defaultValue:NO];
266256
configuration.allowsAirPlayForMediaPlayback = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay" defaultValue:YES];

0 commit comments

Comments
 (0)