Post

Replies

Boosts

Views

Activity

DeviceActivityMonitor Extension Not Working
I added the extension via targets. And I added code in the intervalDidStart() override to print and send a notification. But it never seems to run. Am I supposed to do any other steps after adding the extension? // Make sure that your class name matches the NSExtensionPrincipalClass in your Info.plist. class DeviceActivityMonitorExtension: DeviceActivityMonitor { func getSelectionFromUserDefaults() -> FamilyActivitySelection { let defaults = UserDefaults.standard if let encodedData = defaults.data(forKey: "ScreenTimeSelection") { let decoder = PropertyListDecoder() if let selection = try? decoder.decode(FamilyActivitySelection.self, from: encodedData) { return selection } } return FamilyActivitySelection() } override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) print("HERE!") let content = UNMutableNotificationContent() content.title = "Feed the cat" content.subtitle = "It looks hungry" content.sound = UNNotificationSound.default // show this notification five seconds from now let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false) // choose a random identifier let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) // add our notification request UNUserNotificationCenter.current().add(request) let selection = getSelectionFromUserDefaults() let applications = selection.applicationTokens let categories = selection.categoryTokens let webCategories = selection.webDomainTokens let store = ManagedSettingsStore() store.shield.applications = applications.isEmpty ? nil : applications store.shield.applicationCategories = ShieldSettings.ActivityCategoryPolicy.specific(categories, except: Set()) store.shield.webDomainCategories = ShieldSettings.ActivityCategoryPolicy.specific(categories, except: Set()) }
2
1
813
Jul ’23
Where do I add ShieldConfiguration ?
I am creating a custom shield UI for when an app is blocked. have an AppDelegate file where my @UIApplicationMain is run I pasted in the ShieldConfiguration code from the WWDC21 Meet Screen Time demo inside my app: class MyShieldConfiguration: ShieldConfigurationDataSource { override func configuration(shielding application: Application) -> ShieldConfiguration { return ShieldConfiguration( title: ShieldConfiguration.Label(text: "Doxo", color: UIColor.blue), subtitle: ShieldConfiguration.Label(text: "heyhey") ) } } but after calling store.shield.applications = .... the default restricted screen is being shown instead of the one I configured above Where am I supposed to put MyShieldConfiguration ?
3
0
994
Jul ’23