We got here throughout stories on Medium and Apple Developer Boards suggesting that ApplicationToken and ActivityCategoryToken values issued by the FamilyControls framework are usually not assured to be steady, that iOS might silently re-issue new tokens for a similar apps after OS or app updates, making any beforehand saved tokens invalid. We’re storing FamilyActivitySelection tokens encoded through JSONEncoder to a backend for long-term use, and counting on them inside a DeviceActivityMonitorExtension to revive and apply shields when a schedule fires. What we’re making an attempt to grasp is: is that this token instability nonetheless an lively downside in iOS 16/17/18/26, and when a token does turn out to be invalid, does JSONDecoder really throw a DecodingError giving us a transparent sign, or does it decode efficiently and ManagedSettingsStore simply silently ignore the stale tokens with no error in any respect?
On Medium, We Discovered That
The Token Mutation Downside One of many extra painful bugs in actual manufacturing apps: utility tokens are usually not assured to be steady endlessly. iOS can silently concern new, totally different tokens for a similar app. In case your retailer incorporates the outdated token and the Defend delegate receives a brand new one, the delegate has no solution to match them — it doesn’t know which retailer is accountable for the protect, or which blocking “profile” triggered it. This has been reported by a number of builders of actual Display Time apps and confirmed throughout a number of Apple Developer Discussion board threads. There isn’t a official repair but. The workaround is defensive: when the ShieldConfigurationDataSource or ShieldActionDelegate receives a token you do not recognise, fall again to a generic protect UI quite than crashing or returning empty information. And by no means depend on token identification as a long-term steady key in your persistence layer — at all times re-derive from a recent FamilyActivityPicker choice when the person re-activates a profile.
