Skip to content

Conversation

nan-li
Copy link
Contributor

@nan-li nan-li commented Sep 8, 2025

Description

One Line Summary

Correctly uncache live activities requests, by using an intermediary cast first as a bridge.

Details

Motivation

The SDK was never uncaching live activities requests, as using a safe cast directly to a protocol fails. It might be an issue with bridging from Objective-C or the compiler could not be definitely sure and errs on the side of caution. However it seems casting it to [String: AnyObject] before casting to [String: OSLiveActivityRequest] works. A force-cast also works perhaps by bypassing the first safety layer, but force-casts are dangerous. Fortunately, this alternative seems to work correctly.

Scope

Live activities requests will now be uncached, reduce extraneous requests.

Testing

Unit testing

Added testRequestsUncacheCorrectly that caches and uncaches each live activity request type.

  • test fails before and succeeds after fixe

Manual testing

Testing on physical iPhone 13, iOS 18.6.2

  • reproduced previous casting always failed
  • now it works

Affected code checklist

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

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

This change is Reviewable

Xcode warns:
*** -[NSKeyedUnarchiver decodeObjectForKey:]: value for key (requestSuccessful) is not an object. This will become an error in the future.
@nan-li nan-li changed the title Fix/live activities caching fix: live activities uncaches correctly Sep 8, 2025
* The optional cast directly to a protocol always failed, and this intermediate step of casting to Any/AnyObject was necessary.
@nan-li nan-li force-pushed the fix/live_activities_caching branch from f674d59 to b2d84f0 Compare September 15, 2025 23:03
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