I've been having trouble with .backgroundTask(.appRefresh()) causing an intermittent crash when my app is launched. When the crash happens, the app flashes a darkened screen with the home screen device information (time-of-day, battery life, etc) weirdly pivoted landscape and right-justified. This screen shows for a split-second, disappears, and the app does NOT launch. Re-tapping the app icon will often re-launch the app without incident. After much trouble-shooting, I've discovered that commenting out EITHER @Environment(\.scenePhase) private var phase or the .backgroundTask(.appRefresh()) {} code eliminates the crash, so it's somehow caused by having both present at the same time. As you can see in the example below, it's not even necessary to actually use .scenePhase or .backgroundTask to run any other code in order to create the crash.
The following minimal reproducible example will create the crash on an actual device, although you may need to launch and quit the app in quick succession 10-20 times to see the crash. (I realize most users aren't likely to do that - sometimes the crash occurs in the actual app on the first launch. But it's an intermittent problem so may require a few testing rounds to appear.)
In addition to the code shown here, I've added the "Background Modes" capability with "Background Fetch" to "Signing & Capabilities" and added the "UpdateBadge" task to "Info" as a "Permitted background task scheduler identifier".
Any idea what could be causing the crash and how to prevent it?
struct ToyBackgroundTasksApp: App {
@Environment(\.scenePhase) private var phase
var sharedModelContainer: ModelContainer = {
let schema = Schema([
Item.self,
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(sharedModelContainer)
.backgroundTask(.appRefresh("UpdateBadge")) {
print("background task")
}
}
}
General
RSS for tagDelve 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
I am currently facing an issue when trying to enable Shortcut support and would greatly appreciate your assistance in resolving it.
I have successfully enabled Shortcut support, and I can find my app and its respective functionalities within the Shortcuts app. However, I am unable to locate my app when attempting to create an automation within Shortcuts. I would appreciate any guidance or solutions you may offer regarding this matter.
We developing an app, It's a Parental control app required to block large number of apps. In child mobile installed more than 200 apps parent has to block and disable these apps but parent cant able to block more than 50 apps. Is there any option is there to block all the 200 apps from child mobile.
Is there any way i can show popover tip on tabItem inside of TabView
TabView(selection: selected) {
Group{
HomeView()
.tabItem {
Label {
Text("Home")
} icon: {
Image(selected==1 ? "home-icon" : "home-unselect")
}
// show tip over the Home icon
}
.tag(1)
}
}
I'm trying to implement live caller id PIR server in python and I have an issue related to evaluation key config. I don't receive the POST /key request even if I try to install the extension on new device and I had this error in device system logs:
error 11:21:30.663022+0200 ciphermld requestData(byKeywords:shardIds:clientConfig:) threw an error: CipherML.CipherMLError.missingSecre t Ke y
I think the reason why the evaluation key is not generated is related to this error but I'm not sure. It might be also related to HE params - I tried with the same params as in swift server example with plaintext_modulus=17 and it works, but for plaintext_modulus=65537 on the same device the system doesn't send me the evaluation key. Is there a limitation that restricts the evaluation key generation for some HE params?
There is how the entire config object that I retrieve looks like:
{
"configs": {
"Live-C aller-ID-Lookup. TestLiveCallerI D.iden tity": {
"pir_config": {
"encry ption_p aram eters": {
"pol ynomial_deg ree": "4096",
"plaint ext_mo dulus": "65537",
"coeff icient_m oduli": [
"134176769",
"268369921",
"268361729"
],
"secu rity_le vel": "SECU RITY LEVEL QUANT UM128",
"h e_sc heme": "H E_SC HEM E_B F V"
},
"shard_configs": [
{
"num_entries": "2",
"entry_size": "55991",
"dimensions": [
"2",
"1"
],
"shard_id": ""
}
],
"keyword_pir_params": {
"num_hash_functions": "2",
"sharding_function": {
"sha256": {}
}
},
"algorithm": "PIR _ALGO RITHM _MUL_PIR",
"batch_size": "2",
"evalu ation_ke config_hash": ""
},
"config_id": ""
}
},
"key_info": [
{
"timestamp": "1738660849",
"key_config": {
"encryp tion_par ameters": {
"polynomial_degree": "4096",
"plaintex t_mo dulus": "65537",
"coeffic ient_m oduli": [
"134176769",
"268369921",
"268361729"
],
"secu rity_level": "SECUR ITY_LEVEL_QU ANTUM128",
"he_sc heme": "HE_SC HEME_BFV"
},
"gal ois_e lements": [
20 49,
40 97
],
"has _rel in_key": true
}
}
]
}
PS evaluation key data is just a placeholder, but anyway it should be skipped cause of expired timestamp
More logs:
```language
default 11:21:30.535865+0200 ciphermld Running rotation task for ["Live-Caller-ID-Lookup.TestLiveCallerID.identity"]
info 11:21:30.535953+0200 ciphermld Skipping groups that manage their own networking: <private>
default 11:21:30.537007+0200 ciphermld Request to fetchConfigs has started for useCases '["Li ve-Caller-ID-Lookup.TestLiveCallerID.identity"]', userId: '<private>', existingConfigIds: '["id"]'
default 11:21:30.542174+0200 ciphermld Request to queries-batch has started for userId: '<private>', length: 28350
default 11:21:30.655914+0200 ciphermld Request to fetchConfigs has finished, response length: 230
default 11:21:30.656182+0200 ciphermld Received configurations: 1 usecase(s), 1 key(s) for group 'Live-Caller-ID-Lookup.TestLiveCallerID.identity'
debug 11:21:30.660868+0200 ciphermld Skipping non-active key: timestamp: 1738660849
key_config {
encryption_parameters {
polynomial_degree: 4096
plaintext_modulus: 65537
coefficient_moduli: [134176769, 268369921, 268361729]
security_level: Quantum128
he_scheme: BFV
}
galois_elements: [2049, 4097]
has_relin_key: true
}
error 11:21:30.662982+0200 ciphermld No key for use-case 'Live-Caller-ID-Lookup.TestLiveCallerID.identity'
error 11:21:30.663022+0200 ciphermld requestData(byKeywords:shardIds:clientConfig:) threw an error: CipherML.CipherMLError.missingSecre t Ke y
default 11:21:30.663824+0200 com.apple.CallKit.CallDirectory <private> XPC request complete, results(0) error:Error Domain=CipherML.CipherMLError Code=32 "missing secre t ke y" UserInfo={NSLocalizedDescription=missing secre t ke y}
default 11:21:30.972372+0200 ciphermld Request to queries-batch has finished response, length: 0
default 11:21:30.974711+0200 com.apple.CallKit.CallDirectory <private> XPC request complete, results(1) error:(null)
default 11:21:36.161964+0200 com.apple.CallKit.CallDirectory <private> Sending XPC request
default 11:21:36.163149+0200 com.apple.CallKit.CallDirectory <private> Sending XPC request
default 11:21:36.169931+0200 ciphermld requestData(byKeywords:shardIds:clientConfig:) method was called
default 11:21:36.170448+0200 ciphermld requestData(byKeywords:shardIds:clientConfig:) method was called
default 11:21:36.174001+0200 ciphermld Cached: 0 / Missing: 1
error 11:21:36.174997+0200 ciphermld No userId or secre t Ke y for use-case '.Lve-Caller-ID-Lookup.TestLiveCallerID.identity'. Running rotation task'
default 11:21:36.175075+0200 ciphermld Running rotation task for ["Live-Caller-ID-Lookup.TestLiveCallerID.identity"]
info 11:21:36.175240+0200 ciphermld Skipping groups that manage their own networking: <private>
default 11:21:36.177700+0200 ciphermld Request to fetchConfigs has started for useCases '["Live-Caller-ID-Lookup.TestLiveCallerID.identity"]', userId: '<private>', existingConfigIds: '["id"]'
default 11:21:36.179914+0200 ciphermld Request to queries-batch has started for userId: '<private>', length: 28350
default 11:21:36.336051+0200 ciphermld Request to fetchConfigs has finished, response length: 230
default 11:21:36.336308+0200 ciphermld Received configurations: 1 usecase(s), 1 key(s) for group 'Live-Caller-ID-Lookup.TestLiveCallerID.identity'
debug 11:21:36.341522+0200 ciphermld Skipping non-active key: timestamp: 1738660849
key_config {
encryption_parameters {
polynomial_degree: 4096
plaintext_modulus: 65537
coefficient_moduli: [134176769, 268369921, 268361729]
security_level: Quantum128
he_scheme: BFV
}
galois_elements: [2049, 4097]
has_relin_key: true
}
error 11:21:36.356497+0200 ciphermld No key for use-case 'Live-Caller-ID-Lookup.TestLiveCallerID.identity'
error 11:21:36.356669+0200 ciphermld requestData(byKeywords:shardIds:clientConfig:) threw an error: CipherML.CipherMLError.missingSecre t Ke y
default 11:21:36.357075+0200 com.apple.CallKit.CallDirectory <private> XPC request complete, results(0) error:Error Domain=CipherML.CipherMLError Code=32 "missing secre t ke y" UserInfo={NSLocalizedDescription=missing secre t ke y}
default 11:21:36.625701+0200 ciphermld Request to queries-batch has finished response, length: 0
default 11:21:36.626749+0200 com.apple.CallKit.CallDirectory
Hello.
Recently, there have been many app crash issues of unknown causes.
It has been reported that the app crashes as soon as it is launched, but it is difficult to resolve the issue because it cannot be reproduced.
I have attached the crash log, so please review it and provide appropriate guidance.
Thank you.
2025-02-28_06-02-16.3498_+0900-65dfc1f2a58da46e9ec11a5f0f93f5a56c6858de.crash
In mainland China, CallKit is not available. Recently, I discovered LiveCommunicationKit.
Can it replace CallKit?
There is no relevant introduction in the documentation. Can someone help me understand how to use it?
https://developer.apple.com/documentation/livecommunicationkit
I need to read data from the user. For convenience, the data will be in a property list, so it's easy to get a dictionary containing the property list data. But, since it's coming from outside, I need to validate that the data is in the required format, i.e. it has the right keys and the right sort of data for each key, e.g. <name> has a string, <keys> has an array of appropriate values.
Since this is part of a long-established product, and targets 10.13, I want to do this in Objective-C if possible. I've been working mostly with Swift in recent years, so I've forgotten a lot of what I used to know about Objective-C, I'm sure.
My first thought was to obtain the value for each key and check the class type with isa, but I see that's deprecated in macOS 13 with no replacement. I don't see another way to check the class.
I'm sure other people have solved the same problem, but my searches have not turned up any answers.
Some of our users encounter an issue after updating their iPhone/iPad to iOS 17.5.1.
The tokens passed in the Shield Configuration extension don't match the tokens they selected in my app using the FamilyPicker before updating to iOS 17.5.1. It seems the tokens changed for no reason. My app can't match the token from the ShieldConfigurationDataSource to any tokens stored on my end, causing my shield screens to turn blank. The same applies to tokens in the Device Activity Report extension.
The only workaround I've found is to tell affected users to unselect and reselect apps and websites to block in my app. This gets them new tokens from the FamilyActivityPicker, which solves the issue. However, for some users, the bug reoccurs a few days later. Tokens seem to change again, causing the same issue in the Shield Configuration extension.
I am not able to reproduce the issue on my test devices so I have no sysdiagnose to attach. However, this issue is affecting other screen time apps:
https://developer.apple.com/forums/thread/732845
https://forums.developer.apple.com/forums/thread/756440
FB14082790
FB14111223
A change in iOS 17.5.1 must have triggered this behaviour. Could an Apple engineer give us any updates on this?
I've been seeing a high number of BGTaskScheduler related crashes, all of them coming from iOS 18.4. I've encountered this myself once on launch upon installing my app, but haven't been able to reproduce it since, even after doing multiple relaunches and reinstalls. Crash report attached at the bottom of this post.
I am not even able to symbolicate the reports despite having the archive on my MacBook:
Does anyone know if this is an iOS 18.4 bug or am I doing something wrong when scheduling the task? Below is my code for scheduling the background task on the view that appears when my app launches:
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
#if !os(macOS)
let request = BGAppRefreshTaskRequest(identifier: "notifications")
request.earliestBeginDate = Calendar.current.date(byAdding: .hour, value: 3, to: Date())
do {
try BGTaskScheduler.shared.submit(request)
Logger.notifications.log("Background task scheduled. Earliest begin date: \(request.earliestBeginDate?.description ?? "nil", privacy: .public)")
} catch let error {
// print("Scheduling Error \(error.localizedDescription)")
Logger.notifications.error("Error scheduling background task: \(error.localizedDescription, privacy: .public)")
}
#endif
...
}
2025-02-23_19-53-50.2294_+0000-876d2b8ec083447af883961da90398f00562f781.crash
Hello, I'm having trouble modifying Universal Links in my application
I already have a Universal Links configuration, but now I need to change it to https://iyb-cityapp1.sjdit.com/.well-known/apple-app-site-association. After the configuration is completed, I click this link https://iyb-cityapp1.sjdit.com/index.html in Notes.app and it opens in Safari and does not open the application. What did I do wrong?
Thanks for your help!
Hi folks,
We are trying to develop a widget on iPhone control center. We follow the Apple design guideline to export our resource file using custom icon and the button icon always show on debug build. However, when we deploy to TestFlight, under some scenario, such as app upgrade, we found that the icon image disappear occasionally.
Anyone could help? Thank you in advance!
Hi,
I have a question about On-Demand Resources, I tried to put some bundles into the Initial Install Tags and Download Only On Demand, and I uploaded the build to TestFlight, then I tried to make 2 builds, and the sample is like this:
Build A:
Initial Install Tags have 100 Tags.
Download Only On Demand have 5 Tags.
Build B:
all contents of Initial Install Tags are the same as in Build A.
Download Only On Demand are the same as Build A but I added 5 more tags, so the total is 10 tags, 5 tags that are the same as Build A and 5 new tags.
Then I tried to download Build A for the first time which is in TestFlight, and it runs normally, Initial Install Tags are downloaded when the main app is downloaded and Download Only On Demand is downloaded when I request the tag.
However, when I tried to update to Build B which is in TestFlight, why are the Initial Install Tags deleted? and why should it be downloaded via request? not when the main app is downloaded? has anyone ever experienced something like this?
Thanks!
Overview
I am running a NearbyInteaction sample.
Immediately after niSession.run(configuration!), func session(_ session: NISession, didInvalidateWith error: Error) is executed. The error is as follows, but I cannot find the cause.
Error:
bluetoothPeerIdentifier: AF5ADDC1-F731-7BAD-E8C5-9230E79F8C1A
Session Invalidation Error: NIERROR_ACCESSORY_PEER_DEVICE_UNAVAILABLE_DESCRIPTION
Error Details:Error Domain=com.apple.NearbyInteraction Code=-5882 "NIERROR_ACCESSORY_PEER_DEVICE_UNAVAILABLE_DESCRIPTION" UserInfo={NSLocalizedRecoverySuggestion=NIERROR_ACCESSORY_PEER_DEVICE_UNAVAILABLE_RECOVERY_SUGGESTION, NSLocalizedDescription=NIERROR_ACCESSORY_PEER_DEVICE_UNAVAILABLE_DESCRIPTION, NSLocalizedFailureReason=NIERROR_ACCESSORY_PEER_DEVICE_UNAVAILABLE_FAILURE_REASON}
The sample application worked well at first.
I want the application to run in the background, so I made the following changes and had problems.
Before change:
configuration = try NINearbyAccessoryConfiguration(data: configData)
After change:
configuration = try NINearbyAccessoryConfiguration(
accessoryData: configData,
bluetoothPeerIdentifier: peerIdentifier)
I see no problem with the application. It works fine on device A. The problem occurs on device B.
Device A: NXP QN9090 - NXP SR150
Device B: Nordic nRF52840 - NXP SR150
I have confirmed that the device shows up in the settings app after pairing & bonding the device.
I have confirmed that the iPhone and nRF52840 are still connected to the BLE without any problems when the error occurs.
Initialization code for NearbyInteraction:
func setupAccessory(_ configData: Data, name: String) {
updateInfoLabel(with: "Received configuration data from '\(name)'. Running session.")
do {
guard let discoveredPeripheral = dataChannel.getDiscoveredPeripheral() else {
return
}
let peerIdentifier = discoveredPeripheral.identifier
configuration = try NINearbyAccessoryConfiguration(
accessoryData: configData,
bluetoothPeerIdentifier: peerIdentifier)
} catch {
// Stop and display the issue because the incoming data is invalid.
// In your app, debug the accessory data to ensure an expected
// format.
updateInfoLabel(
with:
"Failed to create NINearbyAccessoryConfiguration for '\(name)'. Error: \(error)"
)
return
}
// Cache the token to correlate updates with this accessory.
cacheToken(configuration!.accessoryDiscoveryToken, accessoryName: name)
niSession.run(configuration!)
}
Environment
Xcode 16.1
iPhone11 (iOS 17.6.1)
Target UWB Chip: NXP SR150
Sample iOS Application: https://developer.apple.com/documentation/nearbyinteraction/implementing-spatial-interactions-with-third-party-accessories
Hi there, I'm facing an issue when disconnecting CarPlay that the navigation session seems to be in some weird state where it is not properly finished. So when I reconnect CarPlay the "Metadata in instrument cluster or HUD" does not update anymore until I start another navigation session and stop that one.
You can see that the instruction to the left on this screen recording is not updating anymore after a reconnect.
https://www.youtube.com/watch?v=sncxyJULjQk
I have a modified the CostalRoad sample app to add support for the HUD cluster and to auto start a navigation simulation when CarPlay connects.
https://github.com/g4rb4g3/CoastalRoads
Can anyone tell me what I have to do when CarPlay disconnect so I can start a new navigation session on reconnect that has a working HUD cluster?
Fun fact is that Apple Maps handles this quite nice (https://www.youtube.com/watch?v=OpJEIyGcwdo), it somehow manages to finish the navigation session and brings up the HUD cluster just fine on reconnect.
I wonder how I can achieve the same, anyone having an idea on that?
I'm trying to use ScreenCaptureKit on a Mac Catalyst app, on macOS 12.5.1.
I'm not sure if I'm doing something wrong, but it crashes as soon as I try to request SCShareableContent. It crashes on internal code, calling a method it can't find, which makes me think this is a bug in the framework rather than incorrect configuration.
Any hints on how to work around this problem?
The crash is:
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RPDaemonProxy fetchShareableContentWithOption:windowID:withCompletionHandler:]: unrecognized selector sent to instance 0x6000037d5dc0'
terminating with uncaught exception of type NSException
ScreenCaptureKit-Crash.txt
We developing a app called Parentgeenee. It's a Parental control app having any limitations on app block from child mobile. Trying to block more than 500 apps but not blocking if any particular method to block a bulk apps.
We developed a camera remote control app for Apple Watch, but during the development process, we found that Apple Watch is prone to sleep on its own without screen interaction (usually automatically sleeping between 5s and 15s when there is no interaction, but our Apple Watch app actually receives the camera preview video frame data we transmit all the time, and there is no data interaction), and then triggers the sessionReachableDidChange function, and the session.isRechable is false. We hope that the camera remote control app for our Apple Watch can remain on when in the foreground, making it convenient to control our camera app on our phone. We found that DJI's Apple Watch app does not automatically sleep and does not sleep for more than 2 minutes. We have tried many methods, such as heartbeat packets, and I have added WKSupportsAlwaysOnDsplay to the Apple Watch info.plist file, but have not found an effective solution. I hope you can provide assistance, thank you.
I am implementing flutter_callkit_incoming for handling call notifications in my Flutter app. However, I am facing an issue where VoIP push notifications are not consistently received when the app is in the background or terminated.
According to Apple’s documentation:
"On iOS 13.0 and later, if you fail to report a call to CallKit, the system will terminate your app. Repeatedly failing to report calls may cause the system to stop delivering any more VoIP push notifications to your app."
I have followed the official installation guide: flutter_callkit_incoming installation and implemented all necessary configurations. However, VoIP notifications sometimes get lost and do not deliver reliably.
Here is the payload I am using:
{
"notification": { "title": "New Alert", "body": "@H is calling you..." },
"android": {
"notification": {
"channelId": "channel_id",
"sound": "sound_name.mp3"
}
},
"apns": { "payload": { "aps": {} } },
"data": {
"title": "New Call",
"body": "@H is calling you...",
"notificationType": "CALL",
"type": "NOTIFICATION",
"sound": "sound_name"
},
"token": "token"
}
I expect the call notification to appear even when the app is in the background or killed state. Has anyone encountered this issue and found a solution? Any insights would be greatly appreciated.
Hello! We're currently testing Live Caller ID implementation and noticed an issue with userIdentifier values in our database.
Initially, we expected to have approximately 100 records (one per user), but the database grew to about 10,000 evaluationKey entries. Upon investigation, we discovered that the userIdentifier (extracted from "User-Identifier" header) for the same device remains constant throughout a day but changes after a few days.
We store these evaluation keys using a composite key pattern "userIdentifier/configHash". All these entries have the same configHash but different userIdentifier values.
This behavior leads to unnecessary database growth as new entries are created for the same users with different userIdentifier values.
Could you please clarify:
Is this the expected behavior for userIdentifier to change over time?
If yes, is there a specific TTL (time-to-live) for userIdentifier?
If this is not intended, could this be a potential iOS bug?
This information would help us optimize our database storage and implement proper cleanup procedures.
Thank you for your assistance!