Post

Replies

Boosts

Views

Activity

DeviceActivityMonitor.intervalDidEnd never getting called
I'm trying to build an app with a DeviceActivityMonitor extension that executes some code after 15 minutes. I can confirm that the extension is set up correctly and that intervalDidStart is executed, but for some reason the intervalDidEnd method never gets called. What I'm doing in both is just registering a local notification. class DeviceActivityMonitorExtension: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { createPushNotification( title: "Session activated!", body: "" ) super.intervalDidStart(for: activity) } override func intervalDidEnd(for activity: DeviceActivityName) { createPushNotification( title: "Session ended", body: "" ) super.intervalDidEnd(for: activity) } private func createPushNotification(title: String, body: String) { let content = UNMutableNotificationContent() content.title = title content.body = body // Configure the recurring date. var dateComponents = Calendar.current.dateComponents([.era, .year, .month, .day, .hour, .minute, .second], from: Date().addingTimeInterval(1.0)) dateComponents.calendar = Calendar.current dateComponents.timeZone = TimeZone.current // Create the trigger as a repeating event. let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false) let uuidString = UUID().uuidString let request = UNNotificationRequest(identifier: uuidString, content: content, trigger: trigger) // Schedule the request with the system. let notificationCenter = UNUserNotificationCenter.current() notificationCenter.add(request) } } And this is the method that is starting the monitoring session: @objc public static func startSession() -> String? { // Calculate start and end times let center = DeviceActivityCenter() let minutes = 15 let startDate = Date().addingTimeInterval(1) guard let endDate = Calendar.current.date(byAdding: .minute, value: minutes, to: startDate) else { return "Failed to create end date?" } // Create date components and explicitly set the calendar and timeZone let startComponents = Calendar.current.dateComponents([.era, .year, .month, .day, .hour, .minute, .second], from: startDate) let endComponents = Calendar.current.dateComponents([.era, .year, .month, .day, .hour, .minute, .second], from: endDate) // Create schedule let schedule = DeviceActivitySchedule( intervalStart: startComponents, intervalEnd: endComponents, repeats: false ) print("Now", Date()) print("Start", startDate, startComponents) print("End", endDate, endComponents) print(schedule.nextInterval) do { // Use a consistent activity name for our simple implementation let activity = DeviceActivityName("SimpleSession") try center.startMonitoring(activity, during: schedule) return nil } catch { return "Failed to start monitoring: \(error)" } } I can confirm my dates & date components make sense with the 4 print statements. Here is the output: Now 2025-02-12 04:21:32 +0000 Start 2025-02-12 04:21:33 +0000 era: 1 year: 2025 month: 2 day: 11 hour: 20 minute: 21 second: 33 isLeapMonth: false End 2025-02-12 04:36:33 +0000 era: 1 year: 2025 month: 2 day: 11 hour: 20 minute: 36 second: 33 isLeapMonth: false Optional(2025-02-12 04:21:33 +0000 to 2025-02-12 04:36:33 +0000) I get the Session activated! notification but never get the Session ended notification. Half an hour later, I've tried debugging the DeviceActivityCenter by printing out the activities property and can see that it is still there. When I try to print out the nextInterval property on the schedule object i get from calling center.schedule(for:), it returns nil. I'm running this on an iPhone 8 testing device with developer mode enabled. It has iOS 16.7.10. I'm totally lost as to how to get this to work.
1
0
151
1w
How to manage child device's apps through an app on parent's phone using Screen Time Controls?
When we request auth from the AuthorizationCenter, it seems that we're only really able to allow users to control the apps on the parent's phone. Is there a way to allow us to let parents manage apps on the kid's device directly through our parent app? For context, we have 2 different apps, one for the parent and one for the child. The child is able to purchase screen time and the parent can redeem them (activate those minutes) from their end.
0
0
185
Jan ’25
How to hide an auto-renewal subscription from App Store manage subscriptions page
I've created 2 auto-renewing products, one with a cheaper price and one with a more expensive price. I show the cheaper product for legacy users (users who have been on the app for a long time). The problem here is that when a user goes to the App Store and manages their subscription there, they are able to see the cheaper option and subscribe to it. Is there a way I can hide the cheaper product from being purchased through the App Store and only allow them to be purchased from my app? I saw the Cleared For Sale option on the product but when I tried unchecking the box, it made it sound like after users' subscription ends, they will no longer continue auto-subscribing to the cheaper option. Or am I misunderstanding Cleared For Sale?
3
1
3.8k
Jan ’22
What is this side bar feature called?
I've gotten a few complaints from some users that are using iPads saying they are unable to interact with certain elements of my app (gestures, taps, touchesbegan/moved don't seem to be working). The issue seems to be spread among the different models but also doesn't happen to all iPads. When I try debugging on any iPad simulator, I don't seem to have any issues with it. I've asked one of them to send me a video of them interacting with the app and the only difference I can see is this side bar. I haven't encountered this before but can't seem to find the name of this feature to look up how to turn it on so I can see if it's causing any issues. Does anyone know what this collapsable menu is called? Also, while I'm here, does anyone know why certain interactions don't work on the iPad?
1
0
677
Sep ’21
Unable to Submit for Review
When I try to submit my app update, I get this error: Unable to Submit for Review The items below are required to start the review process: This field is required However, there aren't any fields that are marked as not required. Here are the things I've checked so far: I've uploaded appropriate sized photos for iPhone 6.5", iPhone 5.5", iPad Pro 12.9" 2nd Gen, iPad Pro 12.9" 3rd Gen. I've ensured that all the phone types in the Media Manager has photos in them. Selected "Free" for app pricing Ensured I accepted the new Paid Apps agreements Double checked that I have a rating selected. Double checked that the certificate for my app is still in my account's certificate list
6
0
1.5k
Apr ’21