Skip to content

Commit 0469f6d

Browse files
Configure ephemeral URLSession for iOS 18.4 simulator to avoid network failures.
1 parent 912d8c0 commit 0469f6d

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

FirebaseRemoteConfig/Sources/RCNConfigFetch.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
2525
#import "FirebaseRemoteConfig/Sources/RCNConfigContent.h"
2626
#import "FirebaseRemoteConfig/Sources/RCNConfigExperiment.h"
27+
#import "FirebaseRemoteConfig/Sources/RCNConfigURLSession.h"
2728
#import "FirebaseRemoteConfig/Sources/RCNDevice.h"
2829
@import FirebaseRemoteConfigInterop;
2930

@@ -640,8 +641,7 @@ - (NSString *)constructServerURL {
640641
}
641642

642643
- (NSURLSession *)newFetchSession {
643-
NSURLSessionConfiguration *config =
644-
[[NSURLSessionConfiguration defaultSessionConfiguration] copy];
644+
NSURLSessionConfiguration *config = [RCNConfigURLSession RemoteConfigURLSession];
645645
config.timeoutIntervalForRequest = _settings.fetchTimeout;
646646
config.timeoutIntervalForResource = _settings.fetchTimeout;
647647
NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface RCNConfigURLSession : NSObject
20+
21+
/// Returns an `NSURLSessionConfiguration` instance suitable for Remote Config requests.
22+
///
23+
/// On iOS 18.4+ and visionOS 2.4+ simulators, this method returns an ephemeral session
24+
/// configuration as a workaround for a network request failure bug. See
25+
/// https://developer.apple.com/forums/thread/777999 for details. For all other environments, the
26+
/// default session configuration is returned.
27+
+ (NSURLSessionConfiguration *)RemoteConfigURLSession;
28+
29+
@end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "RCNConfigURLSession.h"
18+
19+
@implementation RCNConfigURLSession
20+
21+
+ (NSURLSessionConfiguration *)RemoteConfigURLSession {
22+
// Check if the current operating system version meets the criteria of the affected simulators.
23+
if (@available(iOS 18.4, tvOS 100.0, watchOS 100.0, visionOS 2.4, *)) {
24+
// If the app is running on one of the affected simulator versions (or later for iOS and
25+
// visionOS), use an ephemeral session configuration. Ephemeral sessions do not persist caches,
26+
// cookies, or credential data to disk, which circumvents the known bug.
27+
return [[NSURLSessionConfiguration ephemeralSessionConfiguration] copy];
28+
}
29+
return [[NSURLSessionConfiguration defaultSessionConfiguration] copy];
30+
}
31+
32+
@end

0 commit comments

Comments
 (0)