@@ -103,6 +103,8 @@ open class WordPressComRestApi: NSObject {
103
103
104
104
private var invalidTokenHandler : ( ( ) -> Void ) ?
105
105
106
+ private var useEphemeralSession : Bool
107
+
106
108
/**
107
109
Configure whether or not the user's preferred language locale should be appended. Defaults to true.
108
110
*/
@@ -139,14 +141,16 @@ open class WordPressComRestApi: NSObject {
139
141
backgroundSessionIdentifier: String = WordPressComRestApi . defaultBackgroundSessionIdentifier,
140
142
sharedContainerIdentifier: String ? = nil ,
141
143
localeKey: String = WordPressComRestApi . LocaleKeyDefault,
142
- baseURL: URL = WordPressComRestApi . apiBaseURL) {
144
+ baseURL: URL = WordPressComRestApi . apiBaseURL,
145
+ useEphemeralSession: Bool = false ) {
143
146
self . oAuthToken = oAuthToken
144
147
self . userAgent = userAgent
145
148
self . backgroundUploads = backgroundUploads
146
149
self . backgroundSessionIdentifier = backgroundSessionIdentifier
147
150
self . sharedContainerIdentifier = sharedContainerIdentifier
148
151
self . localeKey = localeKey
149
152
self . baseURL = baseURL
153
+ self . useEphemeralSession = useEphemeralSession
150
154
151
155
super. init ( )
152
156
}
@@ -347,7 +351,14 @@ open class WordPressComRestApi: NSObject {
347
351
} ( )
348
352
349
353
private func sessionConfiguration( background: Bool ) -> URLSessionConfiguration {
350
- let configuration = background ? URLSessionConfiguration . background ( withIdentifier: self . backgroundSessionIdentifier) : URLSessionConfiguration . default
354
+ let configuration : URLSessionConfiguration
355
+ if background {
356
+ configuration = . background( withIdentifier: self . backgroundSessionIdentifier)
357
+ } else if useEphemeralSession {
358
+ configuration = . ephemeral
359
+ } else {
360
+ configuration = . default
361
+ }
351
362
352
363
var additionalHeaders : [ String : AnyObject ] = [ : ]
353
364
if let oAuthToken = self . oAuthToken {
0 commit comments