Skip to content

fix: [SDK-5284] parse IAM end_time as UTC instead of device timezone - #2755

Merged
fadi-george merged 2 commits into
mainfrom
fadi/sdk-5284
Sep 18, 2026
Merged

fadi-george merged 2 commits into
mainfrom
fadi/sdk-5284

Conversation

@fadi-george

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Parse and format ISO-8601 Z timestamps in UTC so scheduled In-App Messages stop expiring early (or late) on devices outside UTC.

Details

Motivation

Fixes SDK-5284. A customer in JST (UTC+9) reported that In-App Messages with a schedule end time never displayed on Android, while iOS displayed them correctly.

The server sends IAM end_time as ISO-8601 with a literal Z suffix, for example 2026-09-18T21:30:00.000Z. DateUtils.iso8601Format() used the pattern yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. The quoted 'Z' is a literal character match, not a timezone specifier, so SimpleDateFormat parsed the wall-clock portion in the device's default timezone. On a JST device 21:30Z became 21:30 JST (12:30Z), nine hours early, so InAppMessage.isFinished returned true and the message was skipped.

iOS sets its formatter to UTC and uses XXXXX, which is why the same IAM displayed there.

Scope

  • DateUtils.iso8601Format() now sets the formatter timezone to UTC. The pattern and wire format are unchanged.
  • Affects InAppMessage end time parsing and end_time formatting in toJSONObject().
  • CustomEventBackendService already applied UTC itself, so its payload is unchanged.
  • No public API changes.

Testing

Unit testing

Added DateUtilsTest covering both directions under an Asia/Tokyo default timezone:

  • parsing 2026-09-14T11:30:00.000Z yields the exact UTC instant
  • formatting that instant yields 2026-09-14T11:30:00.000Z

The parse test failed before the fix with a 9 hour offset and passes after. IAM module unit tests pass.

Manual testing

Switched my Mac and Android emulator timezones to Tokyo (UTC+9) and scheduled an IAM to stop showing about 10 minutes in the future. Validated that the IAM displays on both Android and iOS with this branch.

I also validated the original issue on main: with the same setup, iOS displayed the IAM but Android skipped it. Logs on main showed the server end_time of 2026-09-18T21:30:00.000Z being parsed as Fri Sep 18 21:30:00 GMT+09:00 2026 (already in the past). On this branch the same value parses as Sat Sep 19 06:30:00 GMT+09:00 2026 and the IAM displays.

Environment: Android emulator (Pixel, Android 16 / API 36), OneSignal example app, iOS Simulator.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

fadi-george and others added 2 commits September 18, 2026 11:49
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@fadi-george
fadi-george requested a review from a team as a code owner September 18, 2026 21:34
@nan-li
nan-li self-requested a review September 18, 2026 21:36
@github-actions

Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

Diff Coverage Report (Changed Lines Only)

Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff).

Changed Files Coverage

  • DateUtils.kt: 3/3 touched executable lines (100.0%) (4 touched lines in diff)

Overall (aggregate gate)

3/3 touched executable lines covered (100.0% — requires ≥ 80%)

📥 View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants