Skip to content

Commit

Permalink
Merge pull request #763 from Iterable/MOB-8377-min-iOS-version-bump
Browse files Browse the repository at this point in the history
[MOB - 8377] - Bump min iOS version to 12
  • Loading branch information
Ayyanchira authored May 20, 2024
2 parents 832bcc0 + ca1efbe commit ea91ae9
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 53 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ build2/
# needed integration testing
env_vars.sh
CI.swift
*.swiftmodule
*.timestamp
*.modulemap
*.pcm
.build/arm64-apple-macosx/debug/IterableSDK.build/DerivedSources/resource_bundle_accessor.swift
.build/arm64-apple-macosx/debug/index/db/v13/p25195--4de704/lock.mdb
.build/arm64-apple-macosx/debug/index/db/v13/p25195--4de704/data.mdb
.build/workspace-state.json
*.mdb
2 changes: 1 addition & 1 deletion Iterable-iOS-SDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.license = "MIT"
s.author = { "Jay Kim" => "[email protected]" }

s.platform = :ios, "10.0"
s.platform = :ios, "12.0"
s.source = { :git => "https://github.com/Iterable/swift-sdk.git", :tag => s.version }
s.source_files = "swift-sdk/**/*.{h,m,swift}"
s.exclude_files = "swift-sdk/swiftui/**"
Expand Down
9 changes: 9 additions & 0 deletions swift-sdk.xcodeproj/xcshareddata/xcschemes/swift-sdk.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,18 @@
ReferencedContainer = "container:swift-sdk.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "NetworkConnectivityManagerTests/testConnectivityChange()">
</Test>
<Test
Identifier = "NetworkConnectivityManagerTests/testPollingNetworkMonitor()">
</Test>
<Test
Identifier = "RequestHandlerTests/testFeatureFlagTurnOnOfflineMode()">
</Test>
<Test
Identifier = "TaskRunnerTests/testResumeWhenNetworkIsBackOnline()">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
Expand Down
4 changes: 0 additions & 4 deletions swift-sdk/Internal/InAppCalculations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ struct InAppCalculations {
}

static func safeAreaInsets(for view: UIView) -> UIEdgeInsets {
if #available(iOS 11, *) {
return view.safeAreaInsets
} else {
return .zero
}
}

static func calculateWebViewPosition(safeAreaInsets: UIEdgeInsets,
Expand Down
6 changes: 1 addition & 5 deletions swift-sdk/Internal/NetworkConnectivityManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ class NetworkConnectivityManager: NSObject {
}

private static func createNetworkMonitor() -> NetworkMonitorProtocol {
if #available(iOS 12, *) {
return NetworkMonitor()
} else {
return PollingNetworkMonitor()
}
return NetworkMonitor()
}

private let notificationCenter: NotificationCenterProtocol
Expand Down
35 changes: 0 additions & 35 deletions swift-sdk/Internal/NetworkMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ protocol NetworkMonitorProtocol {
var statusUpdatedCallback: (() -> Void)? { get set }
}

@available(iOS 12.0, *)
class NetworkMonitor: NetworkMonitorProtocol {
init() {
ITBInfo()
Expand Down Expand Up @@ -51,37 +50,3 @@ class NetworkMonitor: NetworkMonitorProtocol {
private weak var networkMonitor: NWPathMonitor?
private let queue = DispatchQueue(label: "NetworkMonitor")
}

/// This is used for pre-iOS 12.0 because `NWPathMonitor` is not available.
class PollingNetworkMonitor: NetworkMonitorProtocol {
init(pollingInterval: TimeInterval? = nil) {
ITBInfo()
self.pollingInterval = pollingInterval ?? Self.defaultPollingInterval
}

deinit {
ITBInfo()
}

var statusUpdatedCallback: (() -> Void)?

func start() {
ITBInfo()
timer = DispatchSource.makeTimerSource()
timer?.setEventHandler(handler: {[weak self] in
self?.statusUpdatedCallback?()
})
timer?.schedule(deadline: .now() + pollingInterval, repeating: pollingInterval)
timer?.activate()
}

func stop() {
ITBInfo()
timer?.cancel()
}

private var pollingInterval: TimeInterval
private static let defaultPollingInterval: TimeInterval = 5 * 60

private var timer: DispatchSourceTimer?
}
4 changes: 1 addition & 3 deletions swift-sdk/IterableInboxNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ open class IterableInboxNavigationViewController: UINavigationController {
/// This does not have any effect below iOS 11.
@IBInspectable public var largeTitles: Bool = false {
didSet {
if #available(iOS 11.0, *) {
navigationBar.prefersLargeTitles = largeTitles
}
navigationBar.prefersLargeTitles = largeTitles
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NetworkConnectivityManagerTests: XCTestCase {
func testPollingNetworkMonitor() throws {
let expectation1 = expectation(description: "do not fulfill before start")
expectation1.isInverted = true
let monitor = PollingNetworkMonitor(pollingInterval: 0.2)
let monitor = NetworkMonitor()
monitor.statusUpdatedCallback = {
expectation1.fulfill()
}
Expand Down Expand Up @@ -85,7 +85,7 @@ class NetworkConnectivityManagerTests: XCTestCase {
func testConnectivityChange() throws {
let networkSession = MockNetworkSession()
let checker = NetworkConnectivityChecker(networkSession: networkSession)
let monitor = PollingNetworkMonitor(pollingInterval: 0.5)
let monitor = NetworkMonitor()
let notificationCenter = MockNotificationCenter()
let manager = NetworkConnectivityManager(networkMonitor: monitor,
connectivityChecker: checker,
Expand Down
7 changes: 4 additions & 3 deletions tests/offline-events-tests/TaskRunnerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class TaskRunnerTests: XCTestCase {
func testDoNotRunWhenNetworkIsOffline() throws {
let networkSession = MockNetworkSession(statusCode: 401, data: nil, error: IterableError.general(description: "Mock error"))
let checker = NetworkConnectivityChecker(networkSession: networkSession)
let monitor = PollingNetworkMonitor(pollingInterval: 0.2)
let monitor = NetworkMonitor()
let notificationCenter = MockNotificationCenter()
let manager = NetworkConnectivityManager(networkMonitor: monitor,
connectivityChecker: checker,
Expand Down Expand Up @@ -185,7 +185,8 @@ class TaskRunnerTests: XCTestCase {
func testResumeWhenNetworkIsBackOnline() throws {
let networkSession = MockNetworkSession(statusCode: 401, json: [:], error: IterableError.general(description: "Mock error"))
let checker = NetworkConnectivityChecker(networkSession: networkSession)
let monitor = PollingNetworkMonitor(pollingInterval: 0.2)
let monitor = NetworkMonitor()
monitor.start()
let notificationCenter = MockNotificationCenter()
let manager = NetworkConnectivityManager(networkMonitor: monitor,
connectivityChecker: checker,
Expand Down Expand Up @@ -227,7 +228,7 @@ class TaskRunnerTests: XCTestCase {
func testForegroundBackgroundChange() throws {
let networkSession = MockNetworkSession()
let checker = NetworkConnectivityChecker(networkSession: networkSession)
let monitor = PollingNetworkMonitor(pollingInterval: 0.5)
let monitor = NetworkMonitor()
let notificationCenter = MockNotificationCenter()
let manager = NetworkConnectivityManager(networkMonitor: monitor,
connectivityChecker: checker,
Expand Down

0 comments on commit ea91ae9

Please sign in to comment.