Skip to content

Commit 63c4976

Browse files
committed
Extract OpRepo's poll interval into a constant
* Store in the variable `POLL_INTERVAL_MS` so that it can have a different value for testing vs non-testing
1 parent a7e4958 commit 63c4976

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalCommonDefines.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ typedef enum {GET, POST, HEAD, PUT, DELETE, OPTIONS, CONNECT, TRACE, PATCH} HTTP
255255

256256
// Defines the maximum delay time for confirmed deliveries
257257
#define MAX_CONF_DELIVERY_DELAY 25.0
258+
259+
// Flush interval for operation repo in milliseconds
260+
#define POLL_INTERVAL_MS 5000
258261
#else
259262
// Test defines for API Client
260263
#define REATTEMPT_DELAY 0.004
@@ -272,6 +275,9 @@ typedef enum {GET, POST, HEAD, PUT, DELETE, OPTIONS, CONNECT, TRACE, PATCH} HTTP
272275
// We don't want to delay confirmed deliveries in unit tests
273276
#define MAX_CONF_DELIVERY_DELAY 0
274277

278+
// Reduce flush interval for operation repo in tests
279+
#define POLL_INTERVAL_MS 100
280+
275281
#endif
276282

277283
// A max timeout for a request, which might include multiple reattempts

iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationRepo.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public class OSOperationRepo: NSObject {
4141
var executors: [OSOperationExecutor] = []
4242
var deltaQueue: [OSDelta] = []
4343

44-
// TODO: This should come from a config, plist, method, remote params
45-
var pollIntervalSeconds = 5
44+
// TODO: This could come from a config, plist, method, remote params
45+
var pollIntervalMilliseconds = Int(POLL_INTERVAL_MS)
4646
public var paused = false
4747

4848
/**
@@ -76,7 +76,7 @@ public class OSOperationRepo: NSObject {
7676
}
7777

7878
private func pollFlushQueue() {
79-
DispatchQueue.global().asyncAfter(deadline: .now() + .seconds(pollIntervalSeconds)) { [weak self] in
79+
DispatchQueue.global().asyncAfter(deadline: .now() + .milliseconds(pollIntervalMilliseconds)) { [weak self] in
8080
self?.flushDeltaQueue()
8181
self?.pollFlushQueue()
8282
}

0 commit comments

Comments
 (0)