Skip to content

Commit 633007b

Browse files
Merge pull request #522 from Iterable/tapash/mob-1751-ios-9
[MOB-1751] - Deprecate iOS 9
2 parents 4083874 + e5287f5 commit 633007b

24 files changed

+73
-529
lines changed

Iterable-iOS-SDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
1313
s.author = { "Tapash Majumder" => "[email protected]",
1414
"Jay Kim" => "[email protected]" }
1515

16-
s.platform = :ios, "9.0"
16+
s.platform = :ios, "10.0"
1717
s.source = { :git => "https://github.com/Iterable/swift-sdk.git", :tag => s.version }
1818
s.source_files = "swift-sdk/**/*.{h,m,swift}"
1919
s.exclude_files = "swift-sdk/swiftui/**"

swift-sdk.xcodeproj/project.pbxproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@
150150
AC90C4CD20D8632E00EECA5D /* IterableAppExtensions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC90C4C420D8632D00EECA5D /* IterableAppExtensions.framework */; };
151151
AC90C4E220D8639E00EECA5D /* ITBNotificationServiceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC90C4E120D8639E00EECA5D /* ITBNotificationServiceExtension.swift */; };
152152
AC9355D12589F9F90056C903 /* RequestHandlerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9355D02589F9F90056C903 /* RequestHandlerProtocol.swift */; };
153-
AC9355DB2589FC070056C903 /* LegacyRequestHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9355DA2589FC070056C903 /* LegacyRequestHandler.swift */; };
154153
AC942BC62539DEDA002988C9 /* ResourceHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC942BC52539DEDA002988C9 /* ResourceHelper.swift */; };
155154
AC978D3E24FF953C00372B8C /* NetworkConnectivityChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC978D3D24FF953C00372B8C /* NetworkConnectivityChecker.swift */; };
156155
AC995F992166EE490099A184 /* CommonMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC995F942166EC880099A184 /* CommonMocks.swift */; };
@@ -516,7 +515,6 @@
516515
AC90C4D520D8632E00EECA5D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
517516
AC90C4E120D8639E00EECA5D /* ITBNotificationServiceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ITBNotificationServiceExtension.swift; sourceTree = "<group>"; };
518517
AC9355D02589F9F90056C903 /* RequestHandlerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestHandlerProtocol.swift; sourceTree = "<group>"; };
519-
AC9355DA2589FC070056C903 /* LegacyRequestHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyRequestHandler.swift; sourceTree = "<group>"; };
520518
AC942BC52539DEDA002988C9 /* ResourceHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceHelper.swift; sourceTree = "<group>"; };
521519
AC978D3D24FF953C00372B8C /* NetworkConnectivityChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkConnectivityChecker.swift; sourceTree = "<group>"; };
522520
AC98294A20D9D65E00796DAA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -984,7 +982,6 @@
984982
AC5E888724E1B7AD00752321 /* Request Processing */ = {
985983
isa = PBXGroup;
986984
children = (
987-
AC9355DA2589FC070056C903 /* LegacyRequestHandler.swift */,
988985
ACD2B83C25B0A74A005D7A90 /* Models.swift */,
989986
AC5812F524F3A90F007E6D36 /* OfflineRequestProcessor.swift */,
990987
AC5E888824E1B7CE00752321 /* OnlineRequestProcessor.swift */,
@@ -1757,7 +1754,6 @@
17571754
ACE6888D2228B86C00A95E5E /* InAppInternal.swift in Sources */,
17581755
AC9355D12589F9F90056C903 /* RequestHandlerProtocol.swift in Sources */,
17591756
AC1AA1C924EBB3C300F29C6B /* IterableNotifications.swift in Sources */,
1760-
AC9355DB2589FC070056C903 /* LegacyRequestHandler.swift in Sources */,
17611757
ACFD5AB324C8179D008E497A /* PersistenceHelper.swift in Sources */,
17621758
AC72A0CD20CF4CE2004D7997 /* IterableAppIntegration.swift in Sources */,
17631759
AC72A0CE20CF4CE2004D7997 /* IterableAttributionInfo.swift in Sources */,
@@ -2283,7 +2279,7 @@
22832279
DYLIB_INSTALL_NAME_BASE = "@rpath";
22842280
INFOPLIST_FILE = "swift-sdk/Info.plist";
22852281
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2286-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2282+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
22872283
LD_RUNPATH_SEARCH_PATHS = (
22882284
"$(inherited)",
22892285
"@executable_path/Frameworks",
@@ -2314,7 +2310,7 @@
23142310
ENABLE_TESTABILITY = YES;
23152311
INFOPLIST_FILE = "swift-sdk/Info.plist";
23162312
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2317-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
2313+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
23182314
LD_RUNPATH_SEARCH_PATHS = (
23192315
"$(inherited)",
23202316
"@executable_path/Frameworks",

swift-sdk.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"repositoryURL": "https://github.com/AliSoftware/OHHTTPStubs.git",
77
"state": {
88
"branch": null,
9-
"revision": "e92b5a5746ef16add2a1424f1fc19529d9a75cde",
10-
"version": "9.0.0"
9+
"revision": "12f19662426d0434d6c330c6974d53e2eb10ecd9",
10+
"version": "9.1.0"
1111
}
1212
}
1313
]

swift-sdk/Internal/AppExtensionHelper.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,10 @@ protocol AppWrapperProtocol {
4747
@available(iOSApplicationExtension, unavailable)
4848
class AppWrapper: AppWrapperProtocol {
4949
func openUrl(url: URL) {
50-
if #available(iOS 10.0, *) {
51-
UIApplication.shared.open(url, options: [:]) { success in
52-
if !success {
53-
ITBError("Could not open url: \(url)")
54-
}
50+
UIApplication.shared.open(url, options: [:]) { success in
51+
if !success {
52+
ITBError("Could not open url: \(url)")
5553
}
56-
} else {
57-
_ = UIApplication.shared.openURL(url)
5854
}
5955
}
6056

swift-sdk/Internal/AuthManager.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class AuthManager: IterableAuthManagerProtocol {
3333
hasFailedPriorAuth = false
3434
}
3535

36-
// @objc attribute only needed for the pre-iOS 10 Timer constructor in queueAuthTokenExpirationRefresh
37-
@objc func requestNewAuthToken(hasFailedPriorAuth: Bool = false, onSuccess: AuthTokenRetrievalHandler? = nil) {
36+
func requestNewAuthToken(hasFailedPriorAuth: Bool = false, onSuccess: AuthTokenRetrievalHandler? = nil) {
3837
ITBInfo()
3938

4039
guard !pendingAuth else {
@@ -110,17 +109,8 @@ class AuthManager: IterableAuthManagerProtocol {
110109

111110
let timeIntervalToRefresh = TimeInterval(expirationDate) - dateProvider.currentDate.timeIntervalSince1970 - expirationRefreshPeriod
112111

113-
if #available(iOS 10.0, *) {
114-
expirationRefreshTimer = Timer.scheduledTimer(withTimeInterval: timeIntervalToRefresh, repeats: false) { [weak self] _ in
115-
self?.requestNewAuthToken(hasFailedPriorAuth: false)
116-
}
117-
} else {
118-
// Fallback on earlier versions
119-
expirationRefreshTimer = Timer.scheduledTimer(timeInterval: timeIntervalToRefresh,
120-
target: self,
121-
selector: #selector(requestNewAuthToken),
122-
userInfo: nil,
123-
repeats: false)
112+
expirationRefreshTimer = Timer.scheduledTimer(withTimeInterval: timeIntervalToRefresh, repeats: false) { [weak self] _ in
113+
self?.requestNewAuthToken(hasFailedPriorAuth: false)
124114
}
125115
}
126116

swift-sdk/Internal/DependencyContainer.swift

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -64,47 +64,37 @@ extension DependencyContainerProtocol {
6464
authManager: IterableAuthManagerProtocol,
6565
deviceMetadata: DeviceMetadata,
6666
offlineMode: Bool) -> RequestHandlerProtocol {
67-
if #available(iOS 10.0, *) {
68-
let onlineProcessor = OnlineRequestProcessor(apiKey: apiKey,
69-
authProvider: authProvider,
70-
authManager: authManager,
71-
endPoint: endPoint,
72-
networkSession: networkSession,
73-
deviceMetadata: deviceMetadata,
74-
dateProvider: dateProvider)
75-
if let persistenceContextProvider = createPersistenceContextProvider() {
76-
let healthMonitorDataProvider = createHealthMonitorDataProvider(persistenceContextProvider: persistenceContextProvider)
77-
let healthMonitor = HealthMonitor(dataProvider: healthMonitorDataProvider,
78-
dateProvider: dateProvider,
79-
networkSession: networkSession)
80-
let offlineProcessor = OfflineRequestProcessor(apiKey: apiKey,
81-
authProvider: authProvider,
82-
authManager: authManager,
83-
endPoint: endPoint,
84-
deviceMetadata: deviceMetadata,
85-
taskScheduler: createTaskScheduler(persistenceContextProvider: persistenceContextProvider,
86-
healthMonitor: healthMonitor),
87-
taskRunner: createTaskRunner(persistenceContextProvider: persistenceContextProvider,
88-
healthMonitor: healthMonitor),
89-
notificationCenter: notificationCenter)
90-
return RequestHandler(onlineProcessor: onlineProcessor,
91-
offlineProcessor: offlineProcessor,
92-
healthMonitor: healthMonitor,
93-
offlineMode: offlineMode)
94-
} else {
95-
return RequestHandler(onlineProcessor: onlineProcessor,
96-
offlineProcessor: nil,
97-
healthMonitor: nil,
98-
offlineMode: offlineMode)
99-
}
67+
let onlineProcessor = OnlineRequestProcessor(apiKey: apiKey,
68+
authProvider: authProvider,
69+
authManager: authManager,
70+
endPoint: endPoint,
71+
networkSession: networkSession,
72+
deviceMetadata: deviceMetadata,
73+
dateProvider: dateProvider)
74+
if let persistenceContextProvider = createPersistenceContextProvider() {
75+
let healthMonitorDataProvider = createHealthMonitorDataProvider(persistenceContextProvider: persistenceContextProvider)
76+
let healthMonitor = HealthMonitor(dataProvider: healthMonitorDataProvider,
77+
dateProvider: dateProvider,
78+
networkSession: networkSession)
79+
let offlineProcessor = OfflineRequestProcessor(apiKey: apiKey,
80+
authProvider: authProvider,
81+
authManager: authManager,
82+
endPoint: endPoint,
83+
deviceMetadata: deviceMetadata,
84+
taskScheduler: createTaskScheduler(persistenceContextProvider: persistenceContextProvider,
85+
healthMonitor: healthMonitor),
86+
taskRunner: createTaskRunner(persistenceContextProvider: persistenceContextProvider,
87+
healthMonitor: healthMonitor),
88+
notificationCenter: notificationCenter)
89+
return RequestHandler(onlineProcessor: onlineProcessor,
90+
offlineProcessor: offlineProcessor,
91+
healthMonitor: healthMonitor,
92+
offlineMode: offlineMode)
10093
} else {
101-
return LegacyRequestHandler(apiKey: apiKey,
102-
authProvider: authProvider,
103-
authManager: authManager,
104-
endPoint: endPoint,
105-
networkSession: networkSession,
106-
deviceMetadata: deviceMetadata,
107-
dateProvider: dateProvider)
94+
return RequestHandler(onlineProcessor: onlineProcessor,
95+
offlineProcessor: nil,
96+
healthMonitor: nil,
97+
offlineMode: offlineMode)
10898
}
10999
}
110100

@@ -113,14 +103,9 @@ extension DependencyContainerProtocol {
113103
}
114104

115105
func createPersistenceContextProvider() -> IterablePersistenceContextProvider? {
116-
if #available(iOS 10.0, *) {
117-
return CoreDataPersistenceContextProvider(dateProvider: dateProvider)
118-
} else {
119-
fatalError("Unable to create persistence container for iOS < 10")
120-
}
106+
CoreDataPersistenceContextProvider(dateProvider: dateProvider)
121107
}
122108

123-
@available(iOS 10.0, *)
124109
private func createTaskScheduler(persistenceContextProvider: IterablePersistenceContextProvider,
125110
healthMonitor: HealthMonitor) -> IterableTaskScheduler {
126111
IterableTaskScheduler(persistenceContextProvider: persistenceContextProvider,
@@ -129,7 +114,6 @@ extension DependencyContainerProtocol {
129114
dateProvider: dateProvider)
130115
}
131116

132-
@available(iOS 10.0, *)
133117
private func createTaskRunner(persistenceContextProvider: IterablePersistenceContextProvider,
134118
healthMonitor: HealthMonitor) -> IterableTaskRunner {
135119
IterableTaskRunner(networkSession: networkSession,

swift-sdk/Internal/InAppPresenter.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,13 @@ class InAppPresenter {
3636

3737
InAppPresenter.isPresenting = true
3838

39-
if #available(iOS 10.0, *) {
40-
DispatchQueue.main.async {
41-
self.delayTimer = Timer.scheduledTimer(withTimeInterval: self.maxDelay, repeats: false) { _ in
42-
ITBInfo("delayTimer called")
43-
44-
self.delayTimer = nil
45-
self.present()
46-
}
39+
DispatchQueue.main.async {
40+
self.delayTimer = Timer.scheduledTimer(withTimeInterval: self.maxDelay, repeats: false) { _ in
41+
ITBInfo("delayTimer called")
42+
43+
self.delayTimer = nil
44+
self.present()
4745
}
48-
} else {
49-
// for lack of a better stop-gap, we might as well just present
50-
present()
5146
}
5247
}
5348

swift-sdk/Internal/InternalIterableAPI.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
585585

586586
private func handlePendingNotification() {
587587
if let pendingNotificationResponse = Self.pendingNotificationResponse {
588-
if #available(iOS 10.0, *) {
589-
IterableAppIntegration.implementation?.userNotificationCenter(nil, didReceive: pendingNotificationResponse, withCompletionHandler: nil)
590-
}
588+
IterableAppIntegration.implementation?.userNotificationCenter(nil, didReceive: pendingNotificationResponse, withCompletionHandler: nil)
591589
Self.pendingNotificationResponse = nil
592590
}
593591
}

swift-sdk/Internal/IterableAppIntegrationInternal.swift

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,8 @@ protocol NotificationStateProviderProtocol {
1515

1616
struct SystemNotificationStateProvider: NotificationStateProviderProtocol {
1717
func isNotificationsEnabled(withCallback callback: @escaping (Bool) -> Void) {
18-
if #available(iOS 10.0, *) {
19-
UNUserNotificationCenter.current().getNotificationSettings { setttings in
20-
callback(setttings.authorizationStatus == .authorized)
21-
}
22-
} else {
23-
// Fallback on earlier versions
24-
if let currentSettings = AppExtensionHelper.application?.currentUserNotificationSettings,
25-
currentSettings.types != [] {
26-
callback(true)
27-
} else {
28-
callback(false)
29-
}
18+
UNUserNotificationCenter.current().getNotificationSettings { setttings in
19+
callback(setttings.authorizationStatus == .authorized)
3020
}
3121
}
3222

@@ -45,7 +35,6 @@ public protocol NotificationResponseProtocol {
4535
var userText: String? { get }
4636
}
4737

48-
@available(iOS 10.0, *)
4938
struct UserNotificationResponse: NotificationResponseProtocol {
5039
var userInfo: [AnyHashable: Any] {
5140
response.notification.request.content.userInfo
@@ -144,8 +133,7 @@ struct IterableAppIntegrationInternal {
144133
}
145134

146135
/**
147-
* This method handles incoming Iterable notifications and actions for iOS < 10.
148-
* This also handles 'silent push' notifications for all iOS versions.
136+
* This method handles'silent push' notifications
149137
*
150138
* - parameter application: UIApplication singleton object
151139
* - parameter userInfo: Dictionary containing the notification data
@@ -166,23 +154,6 @@ struct IterableAppIntegrationInternal {
166154
ITBError("messageId not found in 'remove' silent push")
167155
}
168156
}
169-
} else {
170-
switch application.applicationState {
171-
case .active:
172-
break
173-
case .background:
174-
break
175-
case .inactive:
176-
if #available(iOS 10, *) {
177-
} else {
178-
// iOS 10+ notification actions are handled by userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:
179-
// so this should only be executed if iOS 10 is not available.
180-
performDefaultNotificationAction(userInfo)
181-
}
182-
break
183-
@unknown default:
184-
break
185-
}
186157
}
187158

188159
completionHandler?(.noData)
@@ -196,7 +167,6 @@ struct IterableAppIntegrationInternal {
196167
* - parameter completionHandler: Completion handler passed from the original call. Iterable will call the completion handler
197168
* automatically if you pass one. If you handle completionHandler in the app code, pass a nil value to this argument.
198169
*/
199-
@available(iOS 10.0, *)
200170
func userNotificationCenter(_: UNUserNotificationCenter?, didReceive response: NotificationResponseProtocol, withCompletionHandler completionHandler: (() -> Void)?) {
201171
ITBInfo()
202172

@@ -235,7 +205,6 @@ struct IterableAppIntegrationInternal {
235205
completionHandler?()
236206
}
237207

238-
@available(iOS 10.0, *)
239208
private static func createIterableAction(actionIdentifier: String,
240209
userText: String?,
241210
userInfo: [AnyHashable: Any],
@@ -284,7 +253,6 @@ struct IterableAppIntegrationInternal {
284253
return foundButton?[JsonKey.ActionButton.action] as? [AnyHashable: Any]
285254
}
286255

287-
@available(iOS 10.0, *)
288256
private static func createIterableDataFields(actionIdentifier: String, userText: String?) -> [AnyHashable: Any] {
289257
var dataFields = [AnyHashable: Any]()
290258

0 commit comments

Comments
 (0)