Repository navigation
feat: [SDK-5798] use heartbeat_interval_seconds from ios_params - #1815
Conversation
…tbeats Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reject boolean heartbeat intervals, synchronize OSRemoteParamController's params, and clear them on app id change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
abdulraqeeb33
left a comment
There was a problem hiding this comment.
Stacked on new-session-events. This review is only the commits on top of that branch.
Looks good at the current server interval of 1800.
One thing to settle before that interval drops: a cold launch arms the heartbeat before ios params return, and saving params does not restart it. The first uninterrupted foreground visit stays on 1800s even after a successful fetch. The next focus picks up the server value. testIntervalChangeAppliesAfterTheCurrentWait treats the delayed apply as intended. If a shorter value should apply during that first visit, re-arm from the params success block. restartHeartbeat(continuesRecord:) already does nothing when the app is not focused.
A cold launch arms the heartbeat before params return, so the first visit kept the default interval until its wait ended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@abdulraqeeb33 Good catch, fixed in 0ffee58. The params success block now calls |
Description
One Line Summary
Use
sessions.heartbeat_interval_secondsfrom ios_params for the session heartbeat interval.Details
Motivation
The params response now returns the heartbeat interval, but the SDK ignored it and always used a fixed 30 minutes, so the server couldn't change it. Mirrors Android (OneSignal/OneSignal-Android-SDK#2852).
Scope
OSSessionService.heartbeatInterval(remoteParams:)parsessessions.heartbeat_interval_seconds, clamped to 1 minute through 1 day (matching Android). Missing, zero, negative, boolean, or non-numeric values fall back to the 1800 second default.OSSessionServicereads the interval fromOSRemoteParamControlleron each heartbeat check, and the params success block re-arms a running heartbeat, so a cold launch's first visit uses the server interval instead of the default it was armed with. A heartbeat that isn't running (unfocused, or a focus about to start a new session) is not started. The hardcoded constant is removed.OSRemoteParamControllernow synchronizes reads and writes ofremoteParams(and usesdispatch_oncefor its singleton), since heartbeat checks read it from a background queue while a params fetch can replace it.Testing
Unit testing
OSSessionHeartbeatTests,OSSessionServiceTests,OSRemoteLoggingControllerTests,OneSignalTrackerTests, andRemoteParamsTestspass on an iOS 26.5 simulator. The params lock and app id change clear have no dedicated tests (no harness for the full init app id change path).Manual testing
Not tested on device. Current server value (1800) matches the old default, so behavior is unchanged today.
Affected code checklist
Checklist
Overview
Testing
Final pass
🤖 Generated with Claude Code