Skip to content

Commit 6ab7bc9

Browse files
Merge branch 'master' into offline-events
# Conflicts: # swift-sdk/Internal/IterableAPIInternal.swift # swift-sdk/IterableConfig.swift
2 parents d9d9abc + 764eba9 commit 6ab7bc9

File tree

10 files changed

+144
-35
lines changed

10 files changed

+144
-35
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
osx_image: xcode11.3
1+
osx_image: xcode12
22
language: swift
33

44
# if debugging this script, don't forget to check the environment vars on https://travis-ci.com/Iterable/swift-sdk/settings

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## 6.2.11
6+
#### Added
7+
- Xcode 12 and iOS 14 support.
8+
9+
#### Fixed
10+
- Fixed minor warnings.
11+
512
## 6.2.10
613
#### Added
714
- An option to pause automatic in-app displaying has been added. To pause, set `IterableAPI.inAppManager.isAutoDisplayPaused` to `true` (default: `false`).

Iterable-iOS-AppExtensions.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "Iterable-iOS-AppExtensions"
33
s.module_name = "IterableAppExtensions"
4-
s.version = "6.2.10"
4+
s.version = "6.2.11"
55
s.summary = "App Extensions for Iterable SDK"
66

77
s.description = <<-DESC

Iterable-iOS-SDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "Iterable-iOS-SDK"
33
s.module_name = "IterableSDK"
4-
s.version = "6.2.10"
4+
s.version = "6.2.11"
55
s.summary = "Iterable's official SDK for iOS"
66

77
s.description = <<-DESC

swift-sdk.xcodeproj/project.pbxproj

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@
20322032
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
20332033
GCC_WARN_UNUSED_FUNCTION = YES;
20342034
GCC_WARN_UNUSED_VARIABLE = YES;
2035-
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
2035+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
20362036
MTL_ENABLE_DEBUG_INFO = YES;
20372037
ONLY_ACTIVE_ARCH = YES;
20382038
PRODUCT_NAME = IterableSDK;
@@ -2093,7 +2093,7 @@
20932093
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
20942094
GCC_WARN_UNUSED_FUNCTION = YES;
20952095
GCC_WARN_UNUSED_VARIABLE = YES;
2096-
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
2096+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
20972097
MTL_ENABLE_DEBUG_INFO = NO;
20982098
PRODUCT_NAME = IterableSDK;
20992099
SDKROOT = iphoneos;
@@ -2118,7 +2118,7 @@
21182118
DYLIB_INSTALL_NAME_BASE = "@rpath";
21192119
INFOPLIST_FILE = "swift-sdk/Info.plist";
21202120
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2121-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2121+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
21222122
LD_RUNPATH_SEARCH_PATHS = (
21232123
"$(inherited)",
21242124
"@executable_path/Frameworks",
@@ -2148,7 +2148,7 @@
21482148
ENABLE_TESTABILITY = YES;
21492149
INFOPLIST_FILE = "swift-sdk/Info.plist";
21502150
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2151-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2151+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
21522152
LD_RUNPATH_SEARCH_PATHS = (
21532153
"$(inherited)",
21542154
"@executable_path/Frameworks",
@@ -2211,7 +2211,7 @@
22112211
CODE_SIGN_STYLE = Automatic;
22122212
DEVELOPMENT_TEAM = BP98Z28R86;
22132213
INFOPLIST_FILE = "Tests/swift-sdk-swift-tests/Info.plist";
2214-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2214+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
22152215
LD_RUNPATH_SEARCH_PATHS = (
22162216
"$(inherited)",
22172217
"@executable_path/Frameworks",
@@ -2230,7 +2230,7 @@
22302230
CODE_SIGN_STYLE = Automatic;
22312231
DEVELOPMENT_TEAM = BP98Z28R86;
22322232
INFOPLIST_FILE = "Tests/swift-sdk-swift-tests/Info.plist";
2233-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2233+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
22342234
LD_RUNPATH_SEARCH_PATHS = (
22352235
"$(inherited)",
22362236
"@executable_path/Frameworks",
@@ -2258,7 +2258,7 @@
22582258
ENABLE_TESTABILITY = YES;
22592259
INFOPLIST_FILE = "notification-extension/Info.plist";
22602260
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2261-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
2261+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
22622262
LD_RUNPATH_SEARCH_PATHS = (
22632263
"$(inherited)",
22642264
"@executable_path/Frameworks",
@@ -2289,7 +2289,7 @@
22892289
ENABLE_TESTABILITY = YES;
22902290
INFOPLIST_FILE = "notification-extension/Info.plist";
22912291
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2292-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
2292+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
22932293
LD_RUNPATH_SEARCH_PATHS = (
22942294
"$(inherited)",
22952295
"@executable_path/Frameworks",
@@ -2312,7 +2312,7 @@
23122312
CODE_SIGN_STYLE = Automatic;
23132313
DEVELOPMENT_TEAM = BP98Z28R86;
23142314
INFOPLIST_FILE = "Tests/notification-extension-tests/Info.plist";
2315-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
2315+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
23162316
LD_RUNPATH_SEARCH_PATHS = (
23172317
"$(inherited)",
23182318
"@executable_path/Frameworks",
@@ -2335,7 +2335,7 @@
23352335
CODE_SIGN_STYLE = Automatic;
23362336
DEVELOPMENT_TEAM = BP98Z28R86;
23372337
INFOPLIST_FILE = "Tests/notification-extension-tests/Info.plist";
2338-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
2338+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
23392339
LD_RUNPATH_SEARCH_PATHS = (
23402340
"$(inherited)",
23412341
"@executable_path/Frameworks",
@@ -2488,7 +2488,7 @@
24882488
DEVELOPMENT_TEAM = BP98Z28R86;
24892489
ENABLE_TESTABILITY = YES;
24902490
INFOPLIST_FILE = "host-app/Info.plist";
2491-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2491+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
24922492
LD_RUNPATH_SEARCH_PATHS = (
24932493
"$(inherited)",
24942494
"@executable_path/Frameworks",
@@ -2509,7 +2509,7 @@
25092509
DEVELOPMENT_TEAM = BP98Z28R86;
25102510
ENABLE_TESTABILITY = YES;
25112511
INFOPLIST_FILE = "host-app/Info.plist";
2512-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2512+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
25132513
LD_RUNPATH_SEARCH_PATHS = (
25142514
"$(inherited)",
25152515
"@executable_path/Frameworks",
@@ -2573,7 +2573,7 @@
25732573
DEVELOPMENT_TEAM = BP98Z28R86;
25742574
ENABLE_TESTABILITY = YES;
25752575
INFOPLIST_FILE = "ui-tests-app/info.plist";
2576-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2576+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
25772577
LD_RUNPATH_SEARCH_PATHS = (
25782578
"$(inherited)",
25792579
"@executable_path/Frameworks",
@@ -2594,7 +2594,7 @@
25942594
DEVELOPMENT_TEAM = BP98Z28R86;
25952595
ENABLE_TESTABILITY = YES;
25962596
INFOPLIST_FILE = "ui-tests-app/info.plist";
2597-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2597+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
25982598
LD_RUNPATH_SEARCH_PATHS = (
25992599
"$(inherited)",
26002600
"@executable_path/Frameworks",

swift-sdk/Internal/AuthManager.swift

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ import Foundation
77

88
@objc public protocol IterableInternalAuthManagerProtocol {
99
func getAuthToken() -> String?
10+
func resetFailedAuthCount()
1011
func requestNewAuthToken(hasFailedPriorAuth: Bool, onSuccess: ((String?) -> Void)?)
1112
func logoutUser()
1213
}
1314

1415
class AuthManager: IterableInternalAuthManagerProtocol {
1516
init(delegate: IterableAuthDelegate?,
16-
refreshWindow: TimeInterval,
17+
expirationRefreshPeriod: TimeInterval,
1718
localStorage: LocalStorageProtocol,
1819
dateProvider: DateProviderProtocol) {
1920
ITBInfo()
2021

2122
self.delegate = delegate
2223
self.localStorage = localStorage
2324
self.dateProvider = dateProvider
24-
self.refreshWindow = refreshWindow
25+
self.expirationRefreshPeriod = expirationRefreshPeriod
2526

2627
retrieveAuthToken()
2728
}
@@ -36,14 +37,24 @@ class AuthManager: IterableInternalAuthManagerProtocol {
3637
return authToken
3738
}
3839

40+
func resetFailedAuthCount() {
41+
hasFailedPriorAuth = false
42+
}
43+
3944
// @objc attribute only needed for the pre-iOS 10 Timer constructor in queueAuthTokenExpirationRefresh
4045
@objc func requestNewAuthToken(hasFailedPriorAuth: Bool = false, onSuccess: ((String?) -> Void)? = nil) {
46+
guard !pendingAuth else {
47+
return
48+
}
49+
4150
guard !self.hasFailedPriorAuth || !hasFailedPriorAuth else {
4251
return
4352
}
4453

4554
self.hasFailedPriorAuth = hasFailedPriorAuth
4655

56+
pendingAuth = true
57+
4758
delegate?.onAuthTokenRequested { [weak self] retrievedAuthToken in
4859
self?.onAuthTokenReceived(retrievedAuthToken: retrievedAuthToken, onSuccess: onSuccess)
4960
}
@@ -54,8 +65,7 @@ class AuthManager: IterableInternalAuthManagerProtocol {
5465

5566
storeAuthToken()
5667

57-
expirationRefreshTimer?.invalidate()
58-
expirationRefreshTimer = nil
68+
clearRefreshTimer()
5969
}
6070

6171
// MARK: - Private/Internal
@@ -64,10 +74,11 @@ class AuthManager: IterableInternalAuthManagerProtocol {
6474

6575
private var authToken: String?
6676

77+
private var pendingAuth: Bool = false
6778
private var hasFailedPriorAuth: Bool = false
6879

6980
private weak var delegate: IterableAuthDelegate?
70-
private let refreshWindow: TimeInterval
81+
private let expirationRefreshPeriod: TimeInterval
7182
private var localStorage: LocalStorageProtocol
7283
private let dateProvider: DateProviderProtocol
7384

@@ -82,6 +93,8 @@ class AuthManager: IterableInternalAuthManagerProtocol {
8293
}
8394

8495
private func onAuthTokenReceived(retrievedAuthToken: String?, onSuccess: ((String?) -> Void)?) {
96+
pendingAuth = false
97+
8598
authToken = retrievedAuthToken
8699

87100
storeAuthToken()
@@ -98,7 +111,7 @@ class AuthManager: IterableInternalAuthManagerProtocol {
98111
return
99112
}
100113

101-
let timeIntervalToRefresh = TimeInterval(expirationDate) - dateProvider.currentDate.timeIntervalSince1970 - refreshWindow
114+
let timeIntervalToRefresh = TimeInterval(expirationDate) - dateProvider.currentDate.timeIntervalSince1970 - expirationRefreshPeriod
102115

103116
if #available(iOS 10.0, *) {
104117
expirationRefreshTimer = Timer.scheduledTimer(withTimeInterval: timeIntervalToRefresh, repeats: false) { [weak self] _ in
@@ -114,6 +127,11 @@ class AuthManager: IterableInternalAuthManagerProtocol {
114127
}
115128
}
116129

130+
private func clearRefreshTimer() {
131+
expirationRefreshTimer?.invalidate()
132+
expirationRefreshTimer = nil
133+
}
134+
117135
static func decodeExpirationDateFromAuthToken(_ authToken: String) -> Int? {
118136
let components = authToken.components(separatedBy: ".")
119137

swift-sdk/Internal/DependencyContainer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extension DependencyContainerProtocol {
4444

4545
func createAuthManager(config: IterableConfig) -> IterableInternalAuthManagerProtocol {
4646
AuthManager(delegate: config.authDelegate,
47-
refreshWindow: config.authTokenRefreshWindow,
47+
expirationRefreshPeriod: config.expiringAuthTokenRefreshPeriod,
4848
localStorage: localStorage,
4949
dateProvider: dateProvider)
5050
}

swift-sdk/IterableAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import UIKit
99

1010
@objcMembers public final class IterableAPI: NSObject {
1111
/// The current SDK version
12-
public static let sdkVersion = "6.2.10"
12+
public static let sdkVersion = "6.2.11"
1313

1414
/// The email of the logged in user that this IterableAPI is using
1515
public static var email: String? {

swift-sdk/IterableConfig.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public class IterableConfig: NSObject {
127127
/// the number of seconds before expiration of the current auth token to get a new auth token
128128
/// will only apply if token-based authentication is enabled, and the current auth token has
129129
/// an expiration date field in it
130-
public var authTokenRefreshWindow: TimeInterval = 60.0
130+
public var expiringAuthTokenRefreshPeriod: TimeInterval = 60.0
131131

132132
/// If set to true, events will be queued locally when network is offline.
133133
/// When the network is online again, the queued events will be sent to our backend.

0 commit comments

Comments
 (0)