Post

Replies

Boosts

Views

Activity

How to pass Child Class reference as Parent Class
So I have this child class with a function that creates a perdetermined array of other classes. class DirectGame : GameParent { static func GetAllChallenges() -> Array<ChallengeParent>{ return [LockdownChallenge(game: self)] } } These other classes take in a GameParent class in the initalizer like so: class LockdownChallenge { var game : GameParent init(game: GameParent) { self.game = game } } However this line return [LockdownChallenge(game: self)] is throwing the error "Cannot convert value of type 'DirectGame.Type' to expected argument type 'GameParent'" How do I pass in a reference to DirectGame into the initalizer of ChallengeParent?
2
0
319
Aug ’24
Application Tokens from Bundle Identifier
Hello! I've been doing a lot of work with ApplicationTokens, but there is very little documentation. While Apple gives you the FamilyAcitvitiesPicker to get tokens of apps on an iPhone, I need to get the tokens of apps that aren't on the phone. Example: Someone can select Instagram even though they don't have it downloaded. Then the application token will get sent to a server. Then a different person who does have Instagram on their phone will receive the token and it will do something with that application. Because FamilyActivitiesPicker can only select apps on the iPhone that it is running on, FamilyActivitiesPicker is useless to me, leading to my problem: Creating an ApplicationToken without FamilyActivitiesPicker This documentation says that I can create an Application (and thus an ApplicationToken) from the bundle identifier init(bundleIdentifier: String) Creates an object that represents the app with the specified bundle identifier. However, when I try to use this to get instagrams(or any apps) token, it returns nil every time! So, finally, my questions: How do I correctly use this initializer to create an ApplicationToken? Or, if this won't work for my purposes Are the ApplicationTokens created by FamilyActivitiesPicker the same across all devices no matter what?
2
0
472
Aug ’24
Creating ApplicationToken with Decoder from string
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¥Ãn N átJ¹ÿ85B_{VAF fC8. ,,¸¯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?
1
0
325
Aug ’24
How to get which app is currently being used by user
Hello! I'm designing an app that tracks users' screen time and shares it with each other. I've looked extensively into the ScreenTimeAPI and it seems as if Apple doesn't allow any way to share screen time data. Even with the user's permission. I was wondering whether there is a way that my app (running in the background) would be able to get whether the user was currently using the notes app (or any other app). I was looking into the AppTrackingTransparency framework to see if this functionality was at all possible, but came up short of finding an answer. Is this possible? My guess is no but still wanted to check.
1
0
415
Jul ’24