Skip to content

Commit a0c6288

Browse files
No need for clearSharedInstance() after recent changes.
1 parent bad53a3 commit a0c6288

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

Tests/swift-sdk-objc-tests/IterableAPITests.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ - (void)testHandleUniversalLinkRewrite {
124124
[expectation fulfill];
125125
};
126126

127-
[IterableAPI clearSharedInstance];
128127
IterableConfig *config = [[IterableConfig alloc] init];
129128
config.urlDelegate = urlDelegateMock;
130129
[IterableAPI initializeWithApiKey:@"" config:config];
@@ -246,7 +245,6 @@ - (void)testRegisterToken {
246245

247246
IterableConfig *config = [[IterableConfig alloc] init];
248247
config.pushIntegrationName = @"pushIntegration";
249-
[IterableAPI clearSharedInstance];
250248
[IterableAPI initializeWithApiKey:@"apiKey" config:config];
251249
[[IterableAPI sharedInstance] setEmail:@"[email protected]"];
252250
[[IterableAPI sharedInstance] registerToken:[@"token" dataUsingEncoding:kCFStringEncodingUTF8]];
@@ -256,17 +254,15 @@ - (void)testRegisterToken {
256254
}
257255

258256
- (void)testEmailUserIdPersistence {
259-
[IterableAPI clearSharedInstance];
260257
[IterableAPI initializeWithApiKey:@"apiKey"];
261258
[[IterableAPI sharedInstance] setEmail:@"[email protected]"];
262259

263-
[IterableAPI clearSharedInstance];
264260
[IterableAPI initializeWithApiKey:@"apiKey"];
265261
XCTAssertEqualObjects([IterableAPI sharedInstance].email, @"[email protected]");
266262
XCTAssertNil([IterableAPI sharedInstance].userId);
267263

268264
[[IterableAPI sharedInstance] setUserId:@"testUserId"];
269-
[IterableAPI clearSharedInstance];
265+
270266
[IterableAPI initializeWithApiKey:@"apiKey"];
271267
XCTAssertEqualObjects([IterableAPI sharedInstance].userId, @"testUserId");
272268
XCTAssertNil([IterableAPI sharedInstance].email);

Tests/swift-sdk-swift-tests/IterableNotificationResponseTests.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class IterableNotificationResponseTests: XCTestCase {
2121
override func setUp() {
2222
super.setUp()
2323
// Put setup code here. This method is called before the invocation of each test method in the class.
24-
IterableAPI.clearSharedInstance()
2524
IterableAPI.initialize(apiKey:"", config: IterableConfig(), dateProvider: dateProvider)
2625
}
2726

@@ -198,12 +197,9 @@ class IterableNotificationResponseTests: XCTestCase {
198197
dateProvider.currentDate = Calendar.current.date(byAdding: Calendar.Component.hour, value: 24, to: Date())!
199198
XCTAssertNil(api.attributionInfo)
200199
}
201-
200+
201+
@available(iOS 10, *)
202202
func testLegacyDeeplinkPayload() {
203-
guard @available(iOS 10, *) else {
204-
return
205-
}
206-
207203
let messageId = UUID().uuidString
208204
let userInfo: [AnyHashable : Any] = [
209205
"itbl" : [

swift-sdk/IterableAPI+Internal.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ extension IterableAPI {
111111
}
112112
}
113113

114-
// You should not call this.
115-
@objc public static func clearSharedInstance() {
116-
queue.sync {
117-
_sharedInstance = nil
118-
}
119-
}
120-
121114
@objc public func createPostRequest(forAction action: String, withArgs args: [AnyHashable : Any]) -> URLRequest? {
122115
guard let url = getUrlComponents(forAction: action)?.url else {
123116
return nil
@@ -450,9 +443,7 @@ extension IterableAPI {
450443
config: IterableConfig = IterableConfig(),
451444
dateProvider: DateProviderProtocol) -> IterableAPI {
452445
queue.sync {
453-
if _sharedInstance == nil {
454-
_sharedInstance = IterableAPI(apiKey: apiKey, config: config, dateProvider: dateProvider)
455-
}
446+
_sharedInstance = IterableAPI(apiKey: apiKey, config: config, dateProvider: dateProvider)
456447
}
457448
return _sharedInstance!
458449
}

0 commit comments

Comments
 (0)