Delve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.

Post

Replies

Boosts

Views

Activity

About the problem that DeviceActivityMonitorExtension does not work
I am developing an app that can help users disable selected apps at a specified time, so that users can get away from their phones and enjoy real life. Here is my data structure: extension ActivityModel { @NSManaged public var id: UUID @NSManaged public var name: String @NSManaged public var weeks: Data @NSManaged public var weekDates: Data @NSManaged public var appTokens: Data } Among them, weeks is of [Bool] type, indicating which weeks from Sunday to Saturday are effective; weekDates is of [[Date,Date]] type, indicating the effective time period; appTokens is of Set type, indicating the selected apps。 At the beginning, I will open a main monitor: let deviceActivityCenter = DeviceActivityCenter() do{ try deviceActivityCenter.startMonitoring( DeviceActivityName(activityModel.id), during: DeviceActivitySchedule( intervalStart: DateComponents(hour: 0,minute: 0,second: 0), intervalEnd: DateComponents(hour: 23,minute: 59,second: 59), repeats: true ) ) }catch { return false } Since the time range may be different every day, I will start the sub-monitoring of the day every time the main monitoring starts: override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) if activity.rawValue.hasPrefix("Sub-") { ActivityModelManager.disableApps( Tools.getUUIDFromString(activity.rawValue) ) return } let weekIndex = Calendar.current.component(.weekday, from: .now) let weeks = ActivityModelManager.getWeeks(activity.rawValue) if weeks[weekIndex] { let weekDates = ActivityModelManager.getWeekDates(activity.rawValue) let deviceActivityCenter = DeviceActivityCenter() do{ try deviceActivityCenter.startMonitoring( DeviceActivityName("Sub-" + activityModel.id), during: DeviceActivitySchedule( intervalStart: getHourAndMinute(weekDates[weekIndex][0]), intervalEnd: getHourAndMinute(weekDates[weekIndex][1]), repeats: false ) ) }catch { return } }esle { return } } I will judge whether it is main monitoring or sub monitoring based on the different activity names. When the sub-monitor starts, I will get the bound application and then disable it: static func disableApps(_ id : UUID){ let appTokens = ActivityModelManager.getLimitAppById(id) let name = ManagedSettingsStore.Name(id.uuidString) let store = ManagedSettingsStore(named: name) store.shield.applications = appTokens return } When the child monitoring is finished, I resume the application: static func enableApps(_ id : UUID){ let name = ManagedSettingsStore.Name(id.uuidString) let store = ManagedSettingsStore(named: name) store.shield.applications = [] } The above is my code logic. When using DeviceActivityMonitorExtension, I found the following problems: intervalDidStart may be called multiple times, resulting in several sub-monitors being started. After a period of time, the monitoring is turned off. The static methods enableApps and disableApps are sometimes not called
3
0
188
1w
Performance Implications of XPC polling
On my MAC, I have a XPC server running as a daemon. It also checks the clients for codesigning requirements. I have multiple clients(2 or more). Each of these clients periodically(say 5 seconds) poll the XPC server to ask for a particular data. I want to understand how the performance of my MAC will be affected when multiple XPC clients keep polling a XPC server.
4
0
177
1w
Refresh Widget doesn't work from background push notification.
As stated in other posts like: https://developer.apple.com/forums/thread/734488 https://developer.apple.com/forums/thread/652946?answerId=823555022#823555022 Even though the recommended way from Apple documentation is to use push notifications to reload widgets timelines calling WidgetCenter.shared.reloadAllTimelines(), it is unreliable and I couldn't find a pattern of why it works 10% of times and not the other 90%. While the debugger is connected to the App it always works though. My widget needs to reflect updated information otherwise it becomes useless since it display smart home devices states such as the Apple Home widget does as well.
1
0
128
1w
CallDirectoryExtention - How to remove a phone number entry that has already been added if a specific value is retrieved.
The App has the ability to use WebKit and display web pages and the ability to add phone numbers to CallDirectory at specific timing. In this App, when the App is launched or when the Add Contact button on the web page is pressed, CallDirectoryExtention is reloaded from the host app (WebKit-viewController), the phone number is retrieved from the server, and the entry is updated. I would like to add a process to remove the already added phone number entry when a specific value is retrieved from the application server. The specific process we wish to implement is as follows. Step 1: Use URLsession to retrieve values from the application server. (ViewController) Step 2: If the value is a specific value, call a Function that deletes the CallDirectoryExtention entry. (ViewController) Step 3: Delete all entries for the registered phone numbers.
 However, I am aware that I have to use reloadExtension() to call the CallDirectoryExtention process from ViewController on Step2. if I do so, CallDirectoryHandler.beginRequest() will be processed, and I am wondering if it is not possible to execute only the Function that deletes the entry. Is there a way to run only the Function that deletes the CallDirectoryExtention entry from the host app(viewController)?
3
0
198
1w
Issue with RCS Message Filtering on iOS 18.2.1 and 18.3
Hi Apple Developers, I am currently working on a message filtering application and facing issues specifically with filtering RCS (Rich Communication Services) messages. To debug this, I created a sample app that consistently categorizes all incoming messages as "junk." However, the filtering behaviour is inconsistent and not functioning as expected. Here are the key issues observed during testing on iOS versions 18.2.1 and 18.3: Inconsistent Filtering Behavior: When a message is received from an unknown number, it sometimes gets moved to the Junk folder momentarily but is then immediately moved back to the main Messages inbox. In some cases, the message does not get moved to the Junk folder at all, despite the app returning the verdict as "junk." Duplicate Contact Tiles: The Messages app displays two separate conversation tiles for the same mobile number, which is unexpected behavior. For reference, my carrier partner is T-Mobile. Please let me know if you need any additional information to investigate this issue further. Looking forward to your insights and guidance. Best regards, Rijul Singhal
2
1
182
2w
Issue with RCS Message Filtering on iOS 18.2.1 and 18.3
Hi Apple Developers, I am currently working on a message filtering application and facing issues specifically with filtering RCS (Rich Communication Services) messages. To debug this, I created a sample app that consistently categorizes all incoming messages as "junk." However, the filtering behaviour is inconsistent and not functioning as expected. Here are the key issues observed during testing on iOS versions 18.2.1 and 18.3: Inconsistent Filtering Behavior: When a message is received from an unknown number, it sometimes gets moved to the Junk folder momentarily but is then immediately moved back to the main Messages inbox. In some cases, the message does not get moved to the Junk folder at all, despite the app returning the verdict as "junk." Duplicate Contact Tiles: The Messages app displays two separate conversation tiles for the same mobile number, which is unexpected behavior. I have attached both a sample app and a screen recording that clearly demonstrates the issue. The recording shows that the app categorizes messages as junk, yet they still end up in the main Messages inbox. For reference, my carrier partner is T-Mobile. Please let me know if you need any additional information to investigate this issue further. Looking forward to your insights and guidance. Best regards, Rijul Singhal
0
0
120
2w
Extracting the full text of a Siri command prompt
I've been stuck for days trying to figure out how to extract the full text of a Siri prompt that launches my app. We need to be able to get the text of the full command, such as "Hey siri, buy dogfood...." so I can get "dogfood" or anything else following 'buy' . The examples I am finding are a) out of date or b) incomplelete. Right now we're using AppIntents with Shortcuts, but have to use dedicated shortcuts for each specific purchase, which are obviously very limiting.
0
0
131
2w
adding forecastNextHour to dataset significantly changes currentWeather
I have been struggling with getting accurate data from the weatherkit api. It tends to be just different enough from the weather app on the phone. While debugging this I randomly added forecastNextHour to my dataset string and it suddenly made everything match the app and the data looked good. For example there is at this moment a snow storm in Billings. This url: https://weatherkit.apple.com/api/v1/weather/en-US/45.79/-108.50?dataSets=currentWeather,forecastHourly,forecastNextHour&timezone=America/Denver&country=US says that there is heavy snow, and there is a 100% chance for the next few hours. This matches the iOS app. This url without forecastNextHour: https://weatherkit.apple.com/api/v1/weather/en-US/45.79/-108.50?dataSets=currentWeather,forecastHourly&timezone=America/Denver&country=US Says it is hazy and there is a small chance of snow of snow for the next few hours. Like 20-30 percent. This does not match any weather data I can find. I have even checked the forecastStart times and the current weather asOf time. They all match up and are accurate. Is there some unknown reason that without forecastNextHour the API becomes inaccurate? Thanks!
2
0
112
2w
ar Locale default numbering system different between iOS 17 and iOS 18
Hi there The behaviour of using Locale(identifier: "ar") with NumberFormatter.locale appears to have changed between iOS 17 and iOS 18. Is this expected? Steps to reproduce import UIKit func numberFormatter(withlocaleString localeString: String) -> NumberFormatter { let locale = Locale(identifier: localeString) let numberFormatter = NumberFormatter() numberFormatter.locale = locale return numberFormatter } let numbers = 0...9 let localeDigits = numbers let ar_digits = localeDigits.compactMap { numberFormatter(withlocaleString: "ar").string(for: $0)?.first } print(ar_digits) Results The results show: **** numbering system on iOS 17 latn numbering system on iOS 18. iOS Output iOS 17 ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"] iOS 18 ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
1
0
175
2w
Should weather from the following day at midnight be used for the current day?
I just noticed something really odd with WeatherKit. If the temperate at midnight of the FOLLOWING day is colder than all temps in the day you want weather for then WeatherKit will report that as the low temperature for the day even though it's a different day. Here it's reporting the lowest temp for Feb 6 is 22F. But that's a temp from Feb 7. I'm displaying lowTemperature and lowTemperatureTime from DayWeather as well as the HourWeather in these examples. I wasn't sure if this was working as designed or a bug. I can provide raw data from this example. ----daily formatted start weather for Feb 6 High 41° high at Feb 6 at 2 PM Low 22° low at Feb 7 at 12 AM ----daily formatted end Feb 6 at 12 AM 34° Feb 6 at 1 AM 35° Feb 6 at 2 AM 36° Feb 6 at 3 AM 36° Feb 6 at 4 AM 36° Feb 6 at 5 AM 34° Feb 6 at 6 AM 33° Feb 6 at 7 AM 33° Feb 6 at 8 AM 33° Feb 6 at 9 AM 33° Feb 6 at 10 AM 35° Feb 6 at 11 AM 36° Feb 6 at 12 PM 38° Feb 6 at 1 PM 40° Feb 6 at 2 PM 41° Feb 6 at 3 PM 40° Feb 6 at 4 PM 39° Feb 6 at 5 PM 37° Feb 6 at 6 PM 36° Feb 6 at 7 PM 33° Feb 6 at 8 PM 31° Feb 6 at 9 PM 29° Feb 6 at 10 PM 27° Feb 6 at 11 PM 24° Feb 7 at 12 AM 22°
2
0
144
2w
Allowing workaround for FamilyActivityPicker crash
As discussed and acknowledged here, there is a known bug with the FamilyActivityPicker. When a user expands a category that contains enough tokens to exceed the 50mb memory limit, the FamilyActivityPicker crashes. This happens quite frequently for heavy Safari users. An apple engineer mentioned on this thread that WebDomains shown in the picker are present based on the last 30 days of usage data as surfaced by WebKit. Is there any way a user can clear these WebDomains? Either programatically through our app or any other process we can guide them to as a workaround while this issue is getting fixed?
0
1
149
2w
FinanceKit/FinanceStore+FinancialDataAuthorization.swift:27: Fatal error: Process is not entitled
Received entitlement access from Apple yesterday, but I'm getting this error when trying to check app authorization: FinanceKit/FinanceStore+FinancialDataAuthorization.swift:27: Fatal error: Process is not entitled Code of interest: import Foundation import FinanceKit @MainActor class FinanceService: ObservableObject { private let store = FinanceStore.shared @Published private(set) var authorizationStatus: AuthorizationStatus = .notDetermined @Published private(set) var accounts: [Account] = [] @Published private(set) var transactions: [Transaction] = [] @Published private(set) var balances: [AccountBalance] = [] @Published private(set) var wallet: Wallet = Wallet() // Authorization func requestAuthorization() async { do { authorizationStatus = try await store.requestAuthorization() } catch { // If there's an error requesting authorization, set to denied authorizationStatus = .denied print("Error requesting authorization: \(error)") } } func checkAuthorizationStatus() async { do { print("Checking authorization status") authorizationStatus = try await store.authorizationStatus() print("Authorization status: \(authorizationStatus)") } catch { // If there's an error checking status, assume not determined authorizationStatus = .notDetermined print("Error checking authorization status: \(error)") } } } What I've done/checked: Info.plist is set properly, with NSFinancialDataDescription AND NSFinanancialDataUsageDescription both set In my entitlements, key com.apple.developer.financekit is set to financial-data I have am targeting an actual device (min. 17.6) I've followed the instructions here: [https://developer.apple.com/forums/thread/757973] to no avail. Any ideas?
1
0
151
2w
Configuring a MacOS application using MDM preferences
Hello. I have a MacOS application to be distributed in a .pkg that is signed and notarized. For the application to work, it needs some settings defined by us (non-secret strings that differ per client). My thought has been to use a .mobileconfig to send these settings using the com.apple.ManagedClient.preferences PayloadType. I can see these settings land correctly into the /Library/Managed Preferences directory (in the correct domain) when distributed using Apple Business Essentials as the MDM. However, I cannot read the settings using NSUserDefaults OR CFPreferences in objective-c (i've tried with my app unsigned and signed, but not signed ant notarized so far). I've seen some posts here and there about managed preferences being deprecated, so I'm not sure if this is my issue or if i'm simply reading the preferences incorrectly. I'll admit the conflict of some of these posts has me a bit confused about how the preferences subsystem works / whether it should be used at all. I'm on MacOS 15.3. Two questions: Does anything stand out as to why I wouldn't be able to read these properties? Is there a better method I should be using to allow sending config via MDM to set application settings? Thanks in advance!
1
0
97
2w
Blocked calls are blocked but still appearing as unanswered calls in call history
I am using the Call Range Blocker App (App URL: https://apps.apple.com/in/app/call-ranger-spam-call-blocker/id1154832936) to block unwanted calls, so my phone doesn’t ring. However, despite being blocked, these calls still appear as unanswered calls in the call history, which is very frustrating. When users block a number, they expect to block all communication from that number, including call logs. When I contacted the app developer, I was informed that after iOS 18, blocked calls are still showing up as unanswered calls in the call history. I kindly request that Apple’s iOS development team look into this issue and address it in the next update. It is quite annoying to see blocked calls appear in the recent call history, and users would prefer not to have them show up at all. Thank you John
1
0
143
2w
Is quitting the App programatically now allowed?
Hello, I know that in the past it was explicitly forbidden to programmatically end the app, but I cannot find the reference on the current guidelines. The only thing I found was this: https://developer.apple.com/library/archive/qa/qa1561/_index.html but this site has a box on top saying that is not being updated anymore. What is the current policy about this? Is it allowed now? Thank you! :)
1
0
86
2w
Watch Ultra 2: How Do I list my app on Auto-Launch Settings
I'm developing a watchOS app for Watch Ultra 2 that implements water detection using CMSubmersionManager. I would like to make it appear in the Auto-Launch settings menu, but my app is not appearing in the settings (Settings > General > Auto-Launch > When Submerged > Selected App).... What additional steps should I take to make this work? Environment Device: Watch Ultra 2 watchOS: 11.2 Xcode: 16.0 Implementation I have implemented the following as per documentation: Added the Shallow Depth and Pressure capability and Entitlement. Added the "Shallow Depth and Pressure" capability Confirmed entitlement "com.apple.developer.submerged-shallow-depth-and-pressure" was automatically added Note: I initially thought I should use "com.apple.developer.submerged-depth-and-pressure" (without "-shallow") since I'm targeting a maximum depth of 6 meters, but this resulted in compilation errors. ref: https://developer.apple.com/forums/thread/740083 ref: https://developer.apple.com/forums/thread/735296 Added NSMotionUsageDescription and WKBackgroundModes <key>NSMotionUsageDescription</key> <string>Required for water detection</string> <key>WKBackgroundModes</key> <array> <string>underwater-depth</string> </array> According to the documentation: "It also adds your app to the list of apps that the system can autolaunch when the wearer submerges the watch." What additional steps are needed to make the app appear in Auto-Launch settings? Has anyone successfully implemented this feature?
2
0
240
2w
App disappears after pkg installation
We're running into an issue with our pkg bundle where the main .app file disappears after installation and wanted to see if anyone has an idea about what would cause it. We have a pkg bundle with three separate apps, one primary app and two supporting apps. We distribute this pkg bundle directly to our users, who will manually install it on their devices (rather than through the app store). The installation itself will usually complete without any issues, and we aren't seeing anything in the install or system logs indicating that it was removed afterward (our postinstall script checks that all of the files exist and are in the correct locations), but after the installation the main app disappears while the rest of the files (including the supporting apps) we lay down are still present. Sometimes it will fail with an error similar to this: 2024-10-02 09:43:07-04 MBA-L-8114 installer[9894]: Error getting application status info for file:///Applications/.hiddenfolder/app1.app: Error Domain=NSCocoaErrorDomain Code=260 "The file "app1.app" couldn't be opened because there is no such file." UserInfo={NSURL=file:///Applications/.hiddenfolder/app1.app, NSFilePath=/Applications/.hiddenfolder/app1.app, NSUnderlyingError=0x6000026a0d50 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} This only happens on certain computers, but on those computers it will happen consistently. We have noticed that it seems to happen more often with computers that are MDM configured. So far we’ve investigated permissions issues with the build process, installation script issues, and signing/notarizing, but have not found anything that might cause this issue. We did verify that we’re setting BundleIsRelocatable NO in the plist file for our package, so in theory it shouldn’t be trying to move the app after installation (we don't see the main app anywhere on the device so macOS doesn't seem to be moving it). We have another post going into more technical detail here: https://developer.apple.com/forums/thread/769443
0
0
104
2w