I've been working a lot with the FamilyControls API and App Shield recently but have encountered a problem with no documentation. I used the FamilyActivitySelection to select the app store to shield(This is just for testing), and then printed out the application token:
1wfY¸êBòS« öi#×(É?âðwù/jQ¿JïE¢?·¿º<Òd?ýr7¥ÃnNátJ¹ÿ85B_{VAFfC8.,,¸¯3 T7F±õü;¹?v@¯ôÄ\-õ#Ò
I know the application token is a Codable object so I was wondering,
How do I create an application token using the Token<Application>
initializer
init(from: any Decoder) throws
Creates a new instance by decoding from the given decoder.
Using the above data? Do I have to encode first in order to decode it?
For reference, the code I tried to use is:
newValue.applicationTokens.encode(to: JSONEncoder)
if let encoded = try? JSONEncoder().encode(newValue.applicationTokens) {
data = encoded
print(String(data: data, encoding: .utf8)!)
}
if let app = try? JSONDecoder().decode(Token<Application>.self, from: data) {
let token = Application(token: app)
print(token)
} else {
print("didn't work")
}
But it prints didn't work every time.
What should I do differently?