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

ShieldConfiguration not updating when app is open prior to the shield activating
Hello! I believe there is a bug: ShieldConfigurationDataSource extension does not update when the app to be blocked is already open and the ManagedSettingsStore.shield.applications is set to the app that is already open. The shield comes up but has a stale ShieldConfiguration not reflecting the current state of the app is used. I've been able to replicate the issue in an independent app "OffScreen". If you start a blocking time range from 10:00-10:15, it will say "No Twitter until 10:15" and then open Twitter at 10:15. If there is another blocking time range from 10:16-10:31, the app will be open until 10:16 when the shield will reactivate and it will still say "No Twitter until 10:15" when is should say "No Twitter until 10:31". thanks!
4
0
1.4k
Oct ’22
Screentime API new issues on iOS 17.4.1 and 17.5.1
Hi, I have a released screentime app ScreenZen. The last few days I've seen a disturbing spike in bug reports coming from people with 17.4.1 and 17.5.1 phones with no update to the app itself. People reported they saw the issue immediately after updating their iOS version. Unfortunately it is not replicable on all phones with those versions, so we haven't been able to replicate it on our test phones. It appears the issue is the ApplicationToken passed into ShieldActionExtension and ShieldConfigurationExtension does not match any of the ApplicationTokens that the user selected to block through FamilyControls. (The selected ApplicationTokens are being loaded through a group UserDefaults and they are indeed being loaded in the ShieldActionExtension in the bug reports).This is preventing the app from loading the correct settings and handling the blocking accordingly. I am trying to isolate this better with a new release with better logging, but would appreciate any help on this issue.
2
5
1k
Jun ’24
Migrating from CallKit to PushToTalk Framework for PTT Calls — Handling Incoming Calls and Cellular Conflicts
Hello everyone, I’m developing a VoIP-based application that supports both standard VoIP calls and Push-To-Talk (PTT) calls. The app does not use the unrestricted-voip entitlement since it’s not publicly documented or communicated as a standard by Apple. Previously, I handled PTT calls using CallKit after receiving PushKit notifications, but I’m now migrating PTT functionality to the PushToTalk Framework while keeping CallKit for standard VoIP calls. I’m facing a few challenges that I’d like help with: Handling Incoming Push-To-Talk Calls When the App Is Closed and the Device Is Locked I considered continuing to use PushKit notifications to alert users via CallKit and using CallKit until the user brings the app into the foreground, at which point I’d switch to the PushToTalk Framework. While this could technically work, the user experience is not ideal. Are there any recommended approaches for handling PTT calls in this state? Handling Incoming PTT Calls When the App Is in the Background According to Apple documentation, I cannot join a PTT session unless my app is in the foreground. However, in practical scenarios, we often receive incoming PTT calls while the app is in the background. What’s the best solution for this situation? It feels odd to show notifications or use CallKit until the app is foregrounded. Conflict Between Ongoing PushToTalk Call and Incoming Cellular Call Currently, if there’s an ongoing PushToTalk call using the PTT framework and a cellular call comes in, if I receive a PTT transmission and call requestBeginTransmission, the cellular call is ended. I can handle this within my app, but is this expected behavior? Is this the intended conflict management for concurrent PTT and cellular calls? Lastly, a broader question: when will the unrestricted-voip entitlement stop working? I’m contemplating using this entitlement to handle incoming PTT calls without CallKit, but I’m concerned about its longevity. Some apps have been using it for messaging and other features for over four years, and it’s still functional for them. Any guidance or insights on these points would be greatly appreciated! Thanks in advance!
1
0
250
3w
Message Filter Extension not working with iOS 18 RC
If I run an app with a message filter extension on a phone with iOS 17.N then it works as expected. However if I run the same app (totally unchanged) on a phone with iOS 18 RC then there's multiple problems. I noticed there's no longer any logging from the extension in the Console (while there is for iOS 17 devices) in the messages app the filter sub categories aren't displayed (but they are on iOS 17 devices) if I try to debug the extension and place breakpoints in it, then there's an exception that occurs when the extension is enabled and the OS logs this (this doesn't occur with iOS 17 devices) '/private/preboot/Cryptexes/OS/usr/lib/swift/libswiftIdentityLookup.dylib' (no such file), '/usr/lib/swift/libswiftIdentityLookup.dylib' (no such file, not in dyld cache) I tried running on: iPhone with iOS 17.6 - no problems iPhone with iOS 18.1 beta - has all the above problems iPhone with iOS 18 RC - has all the above problems Was surprised the RC is so broken in this area as its release will be imminent. As things stand, I can't get a MFE to work at all with iOS 18. Anybody else with the same issues?
0
1
189
3w
Missing Library Error in Mac Catalyst when distributed through Testflight
The iOS version of the app is functioning correctly on TestFlight, and there are no issues when building the Mac Catalyst version of the app from Xcode. However, when distributing the app to TestFlight for Mac Catalyst, the FFmpegkit library fails to load, resulting in a crash. The crash report indicates that the library is missing and cannot be located in the designated file path. Specifically, the crash report states that the library could not be loaded from "@rpath/ffmpegkit.framework/ffmpegkit". Despite extensive efforts, I have been unable to resolve this issue. This is error message in the crash report. Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: @rpath/ffmpegkit.framework/ffmpegkit Referenced from: <9162F8B0-7112-310B-8EDA-59766087927F> /Applications/MyApp.app/Contents/MacOS/MyApp Reason: tried: '/System/Library/Frameworks/ffmpegkit.framework/ffmpegkit' (no such file, not in dyld cache), (security policy does not allow @ path expansion) (terminated at launch; ignore backtrace) Are there any alternative solutions to resolve this problem? This is all the things I have already tried: I tried most of the solutions mentioned in the post below. https://stackoverflow.com/questions/24333981/ios-app-with-framework-crashed-on-device-dyld-library-not-loaded-xcode-6-beta I checked the package content found in Testflight and the paths are correctly matching the following /System/Library/Frameworks/ffmpegkit.framework/ffmpegkit I ran the app scheme as release within Xcode and it build and ran fine with no issues I manually loaded the signing certificates for mac catalyst and still getting the error Deleted all derived data Deleted and reinstalled Xcode and also tried previous Xcode versions. Deleted the project completely
5
1
1k
Apr ’23
CarPlay / Siri: single message display
We have an app with carplay-messaging capability, and have successfully integrated our app in order to read out the list of unread messages. However, if a single message arrives and our push notification appears, we are not able to have the Siri UI automatically read only that single message or announce it. The 'list' UI appears (siri: "would you like to read your messages...") when tapping the notification, whereas we would like the 'item' UI to appear immediately with the "reply, repeat, don't reply" buttons. Our intent handler service looks like this - basically the auto-generated one for a new Intent Handler Extension: import Intents // As an example, this class is set up to handle Message intents. // You will want to replace this or add other intents as appropriate. // The intents you wish to handle must be declared in the extension's Info.plist. // You can test your example integration by saying things to Siri like: // "Send a message using <myApp>" // "<myApp> John saying hello" // "Search for messages in <myApp>" class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessagesIntentHandling, INSetMessageAttributeIntentHandling { override func handler(for intent: INIntent) -> Any { // This is the default implementation. If you want different objects to handle different intents, // you can override this and return the handler you want for that particular intent. return self } // MARK: - INSendMessageIntentHandling // Implement resolution methods to provide additional information about your intent (optional). func resolveRecipients(for intent: INSendMessageIntent, with completion: @escaping ([INSendMessageRecipientResolutionResult]) -> Void) { if let recipients = intent.recipients { // If no recipients were provided we'll need to prompt for a value. if recipients.count == 0 { completion([INSendMessageRecipientResolutionResult.needsValue()]) return } var resolutionResults = [INSendMessageRecipientResolutionResult]() for recipient in recipients { let matchingContacts = [recipient] // Implement your contact matching logic here to create an array of matching contacts switch matchingContacts.count { case 2 ... Int.max: // We need Siri's help to ask user to pick one from the matches. resolutionResults += [INSendMessageRecipientResolutionResult.disambiguation(with: matchingContacts)] case 1: // We have exactly one matching contact resolutionResults += [INSendMessageRecipientResolutionResult.success(with: recipient)] case 0: // We have no contacts matching the description provided resolutionResults += [INSendMessageRecipientResolutionResult.unsupported()] default: break } } completion(resolutionResults) } else { completion([INSendMessageRecipientResolutionResult.needsValue()]) } } func resolveContent(for intent: INSendMessageIntent, with completion: @escaping (INStringResolutionResult) -> Void) { if let text = intent.content, !text.isEmpty { completion(INStringResolutionResult.success(with: text)) } else { completion(INStringResolutionResult.needsValue()) } } // Once resolution is completed, perform validation on the intent and provide confirmation (optional). func confirm(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) { // Verify user is authenticated and your app is ready to send a message. let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self)) let response = INSendMessageIntentResponse(code: .ready, userActivity: userActivity) completion(response) } // Handle the completed intent (required). func handle(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) { // Implement your application logic to send a message here. let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self)) let response = INSendMessageIntentResponse(code: .success, userActivity: userActivity) completion(response) } // Implement handlers for each intent you wish to handle. As an example for messages, you may wish to also handle searchForMessages and setMessageAttributes. // MARK: - INSearchForMessagesIntentHandling func handle(intent: INSearchForMessagesIntent, completion: @escaping (INSearchForMessagesIntentResponse) -> Void) { // Implement your application logic to find a message that matches the information in the intent. let userActivity = NSUserActivity(activityType: NSStringFromClass(INSearchForMessagesIntent.self)) let response = INSearchForMessagesIntentResponse(code: .success, userActivity: userActivity) // Initialize with found message's attributes response.messages = [INMessage( identifier: "identifier", conversationIdentifier: "convo1", content: "I am so excited about SiriKit!", dateSent: Date(), sender: INPerson(personHandle: INPersonHandle(value: "sarah@example.com", type: .emailAddress), nameComponents: nil, displayName: "Sarah", image: nil, contactIdentifier: nil, customIdentifier: nil), recipients: [INPerson(personHandle: INPersonHandle(value: "+1-415-555-5555", type: .phoneNumber), nameComponents: nil, displayName: "John", image: nil, contactIdentifier: nil, customIdentifier: nil)], messageType: .text )] completion(response) } // MARK: - INSetMessageAttributeIntentHandling func handle(intent: INSetMessageAttributeIntent, completion: @escaping (INSetMessageAttributeIntentResponse) -> Void) { // Implement your application logic to set the message attribute here. let userActivity = NSUserActivity(activityType: NSStringFromClass(INSetMessageAttributeIntent.self)) let response = INSetMessageAttributeIntentResponse(code: .success, userActivity: userActivity) completion(response) } } Is there specific configuration required to allow display of a single message via tapping on the notification?
3
0
277
Aug ’24
Zombie CKQuerySubscription
I am converting my subscriptions to shouldBadge=NO; and adding silent notifications to implement my own badge count incrementation now that setApplicationIconBadgeNumber: doesn't work. (see [https://stackoverflow.com/questions/47542005/ckmodifybadgeoperation-is-deprecated-in-ios-11-anyone-know-an-alternative-appro] The problem is that I still have subscriptions with shouldBadge=YES; triggering. I cannot delete those subscriptions because they do not appear in a fetchAllSubscriptionsWithCompletionHandler: . I think I may have deleted the subscriptions from the Development and Production environments on the dashboard and that is why they do not appear in the fetch. But they still exist and are firing over and over again - and setting the badge. Does anyone know how to delete a subscription that can't be fetched?
1
0
209
Sep ’24
Widget loader/redact on fetch from server
I have a widget that displays data which is fetched from the server asynchronously. The widget contains a refresh button. The data is refreshed either when the app goes to the background of when the user taps the refresh button (timeline policy is .never) Since the request may take more than 2 seconds, I would like to display a redact effect until the data is returned. Lets say the timeline entry contains isRedact property. I would like to see the following happen: 1a. user taps refresh button 1b. widget is redrawn with redact state do to entry.isRedact=true 2a. data is fetched asynchronously 2b. on return widget is redrawn without redact state do to entry.isRedact=false From what I understand, the widget is re-drawn only as a result of getTimeline entries, so I don't understand how to make 1b happen, since 1b is an entry that can be created immediately but 2b entry can only happen async Of course there might be another way to redraw a widget that I don't know.
4
0
236
3w
Do we need a server to use the Screen Time API?
I want to create an app to control a child's device. As I understand it, I need to follow this logic: I have one app for both the child and the parent. For the child, I request authorization with the following code: try await AuthorizationCenter.shared.requestAuthorization(for: .child) For the parent, I show functions like: familyActivityPicker Are these settings automatically applied to the child's device, or do I need to send a silent push notification to apply the new settings? Additionally, how can I get statistics from the child's device to the parent's device?
1
0
218
3w
iOS 18: Detect iPhone Mirroring
Is there a way for an iOS app to detect if it is being mirrored to a Mac using a new iPhone Mirroring feature, introduced in iOS 18 and macOS 15 Sequoia? I believe there are a dozen use-cases an app developer may want to know such a thing. For example, imagine rewarding a user for performing some tasks. Performing a task using iPhone Mirroring would give some users advantage, which would have to be weighted in.
6
1
668
Jul ’24
Infer error domain and code from localizedDescription
I have been bitten by this repeatedly so I am finally going to ask: Is there a way to infer an error from its localizedDescription only? It sometimes happens that a user reaches out for support with just a localized error message, but no error code or error domain and it is really hard to correctly guess what the non-localized description may have been in order to search for it. For example I know from experience that "Der eingegebene Benutzername oder das Passwort ist ungültig." is the German localization of "The user name or passphrase you entered is not correct." which in turn is errSecAuthFailed (aka. -25293). It would be really helpful to be able to just look this up somewhere...
2
0
214
3w
ControlWidgetToggle icon format
What format can the image be in for a ControlWidgetIcon? Can we use .svg and .png? Or does it have to be a systemImage? In XCode16-beta4 this code worked: AppIntentControlConfiguration( kind: WidgetConfig.Constants.controlCenterLock, provider: Provider()) { value in ControlWidgetToggle( "Lock/Unlock", isOn: !value.isLocked, action: LockUnlockToggleIntent(), valueLabel: { isUnlocked in Label( isUnlocked ? "Unlocked" : "Locked", image: isUnlocked ? "controlUnlocked" : "controlLocked") }) }) Where "controlUnlocked"/"controlLocked" were the names of Assets in the Widget extension asset catalogue. But in XCode-beta 6, the icons show a question mark. I can only get icons to show by using systemImage Label( isUnlocked ? "Unlocked" : "Locked", systemImage: isUnlocked ? "lock.open": "lock.fill" ) Is it a bug that it isn't loading the icons? Is there a format for the icons? Or are only systemImage icons supported?
2
0
212
Aug ’24
如何在安装APP后,可以在系统的快捷指令APP中直接看到并使用超过10个以上的自定义快捷指令
使用APPIntent 的AppShortcutsProvider方式,最多只能添加10个AppShortcut,超过10个,代码编译就会报错 struct MeditationShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: StartMeditationIntent(), phrases: [ "Start a (.applicationName)", "Begin (.applicationName)", "Meditate with (.applicationName)", "Start a (.$session) session with (.applicationName)", "Begin a (.$session) session with (.applicationName)", "Meditate on (.$session) with (.applicationName)" ] ) } } 如何能做到像特斯拉APP一样
0
1
190
4w
Open parent app from ShieldAction extension in iOS
When I tap on one of the buttons in the ShieldAction extension I want to close the shield and open the parent app instead of the shielded app. Is there any way of doing this using the Screen Time API? class ShieldActionExtension: ShieldActionDelegate {      override func handle(action: ShieldAction, for application: ApplicationToken, completionHandler: @escaping (ShieldActionResponse) -> Void) {     // Handle the action as needed.           let store = ManagedSettingsStore()               switch action {     case .primaryButtonPressed:       //TODO - open parent app       completionHandler(.defer)     case .secondaryButtonPressed:       //remove shield       store.shield.applications?.remove(application)       completionHandler(.defer)         @unknown default:       fatalError()     }   }   }
8
5
3.1k
Nov ’22
Issues with iOS 16 AppIntents after building app with iOS 17 SDK
I'm running into a couple of breaking issues with AppIntents for which I just submitted feedbacks. I figured I'd post them on the forum too for good measure. FB12701143 - @IntentParameterDependency causing crashes in all AppIntents with Entity Queries on iOS 16 I have a pre-existing AppIntent with its own EntityQuery that works just fine on iOS 16. I've built a totally separate intent only available in iOS 17 that makes use of a new entity and a new query using @IntentParameterDependency, but now the original intent crashes after building and running the app on an iOS 16 device with the latest Xcode beta. The line it crashes on is the initializer of the iOS 17-only EntityQuery, even though 1) it shouldn't be able to see it and 2) that EntityQuery isn't involved in the crashing intent. This breaks significant functionality in my AppIntents, and I'm hoping this is a bug rather than a framework limitation. The feedback includes a sample project, crash log, and sysdiagnose. FB12701491 - iOS 17-only CustomIntentMigratedAppIntent stops SiriKit intent equivalent from working on iOS 16 I have a SiriKit intent in my app that I was not able to convert to an AppIntent until iOS 17 because it makes use of an @IntentParameterDependency. However, even though the new AppIntent version is marked as only available in iOS 17 and above, once I conform it to CustomIntentMigratedAppIntent and provide the old intent’s class name, it stops working on iOS 16 devices with an error that the shortcut is unavailable on that device. The CustomIntentMigratedAppIntent should respect the iOS 17 availability annotation and leave the SiriKit intent alone since its migrated replacement isn’t available on iOS 16. The feedback includes a sample project illustrating the issue.
3
0
1k
Jul ’23
Sirikit "Create" category show create button but siri don't accept "create" command
I develop a siri function with my App. In the custom intent, I choose "Create" category. And when I run this command, create button would be displayed. But the strange thing, when I say "create", no response. I say "yes", "okay", "sure", all of them worked. Only "create", didn't work. If we show a create button, the "create" command also need work. Can anyone help me, I want "create" command also worked.
1
0
195
Aug ’24
Can you call the ManagedSettings framework from your main app?
I am working on a screen time app that helps individuals shield distracting apps and web content. Assuming one is granted the Family Controls entitlement and a user accepts the Family Controls authorization request, can you call the ManagedSettings framework from your main app? Is this framework only allowed to be used within the context of a Device Activity Monitor Extension? I'm unsure if this type of usage will result in an instant rejection from App Review?
0
0
246
3w