Skip to content

Commit b2d84f0

Browse files
committed
fix to correctly uncache live activity requests
* The optional cast directly to a protocol always failed, and this intermediate step of casting to Any/AnyObject was necessary.
1 parent 5fb7b7e commit b2d84f0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

iOS_SDK/OneSignalSDK/OneSignalLiveActivities/Source/Executors/OSLiveActivitiesExecutor.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class RequestCache {
4848
init(cacheKey: String, ttl: TimeInterval) {
4949
self.cacheKey = cacheKey
5050
self.ttl = ttl
51-
self.items = OneSignalUserDefaults.initShared()
52-
.getSavedCodeableData(forKey: cacheKey, defaultValue: nil) as? [String: OSLiveActivityRequest] ?? [String: OSLiveActivityRequest]()
51+
let cached = OneSignalUserDefaults.initShared().getSavedCodeableData(forKey: cacheKey, defaultValue: nil)
52+
// for safe-casting to the protocol, the intermediary cast to AnyObject is necessary
53+
self.items = cached as? [String: AnyObject] as? [String: OSLiveActivityRequest] ?? [String: OSLiveActivityRequest]()
5354
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "OneSignal.LiveActivities initialized token cache \(self): \(items)")
5455
}
5556

0 commit comments

Comments
 (0)