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

iOS did not update all widgets of an app when the user press a button on a widget
Hello, I have an app in AppStore "Counter Widget". https://apps.apple.com/app/id1522170621 It allows you to add a widget to your homescreen/lockscreen to count anything. Everything works fine except for one scenario. iOS 18+ I create 2 or more widgets for one counter. For example, medium and small widgets. I click on the widget button to increase or decrease the value. The button in the widget uses Button(intent: AppIntent) to update the value and calls WidgetCenter.shared.reloadAllTimelines() to update the second widget for the same counter. For iOS 18 in this particular scenario, you don't even have to call the WidgetCenter.shared.reloadAllTimelines(). iOS already knows that there is a widget with the same INIntent settings and will update it itself. Both widgets are updated and show the new value. Everything is correct. Now on the homescreen I open the widget configuration for one of the widgets to change the INIntent for the widget. For example, i change the background to wallpaper. This is just a skin for the widget, and the widget is associated with the same counter value as before. As in (2), I click the widget button to increase or decrease the value. But now only one widget is updated. iOS ignores my call to WidgetCenter.shared.reloadAllTimelines() and does not update the second widget connected to the same counter. As I found, iOS, when I call WidgetCenter.shared.reloadAllTimelines() from the widget itself, updates other widgets only if INIntent is absolutely equal for them. Overriding isEqual for them did not help. That is, I cannot specify which fields from my INIntent can be ignored during such an update and consider that widgets are equal and need to be updated. Obviously iOS make this compare outside my code. The main problem is that when the user adds a widget to the lock screen and increases and decreases the value there. After that, he opens the home screen and the widget there is not synchronized with the value from the widget on the lock screen. How to solve this problem?
3
0
132
1w
Is there a way for my macos app to run NSRunningApplication.terminate()?
When my macOS app (currently in TestFlight and set for Mac App Store distribution) tries to terminate another app, both terminate() and forceTerminate() consistently return false. However, I can retrieve a list of all running applications so some related APIs do work. I suspect this limitation is due to sandboxing. I have three questions: Is there any permission or entitlement I can add in Xcode to allow my app to terminate other applications? If no such permission exists, is there a way to guide users on how to launch my app (distributed through the Mac App Store) without sandboxing? For example, could they set it up to launch as a daemon or agent? If unsandboxing is impossible, would I need to create a separate target specifically without sandboxing? In other words, my MacOS app would communicate with my unsandboxed daemon that would do all the terminate()-ing?
1
0
88
1w
Pull data on iOS App Homescreen Widget
Hello fellow developers! I am interested in obtaining the following information regarding one of our Home Screen widgets: Pull the following data about the "my_app_widget" homepage widget in total and by month for the last 12 months (Sep '23 - Sep '24): Widget install events Unique widget installs Device type (iPad, iOS). Thus far, I am using AWS Lambda and have the proper credentials within a Secrets Manager and I keep getting a 409 error from this code: const AWS = require('aws-sdk'); const axios = require('axios'); const jose = require('jose'); const crypto = require('crypto'); const s3 = new AWS.S3(); const secretsManager = new AWS.SecretsManager(); const cloudwatchlogs = new AWS.CloudWatchLogs(); const logGroupName = '/aws/lambda/my_lambda_function'; const logStreamName = '2024/11/05/[$LATEST]XXXXXXXXXXXXXX'; const getSecret = async (secretName) => { const secret = await secretsManager.getSecretValue({ SecretId: secretName }).promise(); return JSON.parse(secret.SecretString); }; const logError = async (message) => { const params = { logGroupName, logStreamName, logEvents: [ { message: JSON.stringify(message), timestamp: Date.now() } ] }; try { await cloudwatchlogs.putLogEvents(params).promise(); } catch (error) { console.error('Failed to log to CloudWatch:', error); } }; const getJwtToken = async (keyId, issuerId, privateKeyPem) => { try { const privateKey = crypto.createPrivateKey({ key: privateKeyPem, format: 'pem', type: 'pkcs8' }); const payload = { iss: issuerId, exp: Math.floor(Date.now() / 1000) + 20 * 60, aud: 'appstoreconnect-v1' }; const token = await new jose.SignJWT(payload) .setProtectedHeader({ alg: 'ES256', kid: keyId }) .sign(privateKey); return token; } catch (error) { await logError({ error: 'Error generating JWT', details: error }); throw new Error('JWT generation failed'); } }; const fetchAndUploadReport = async (url, token, s3Key, isAnalytics = false, body = null) => { try { const headers = { 'Authorization': `Bearer ${token}`, 'Accept': isAnalytics ? 'application/json' : 'application/a-gzip', 'Content-Type': 'application/json' }; const response = await axios({ method: isAnalytics ? 'post' : 'get', url: url, headers: headers, data: body, responseType: isAnalytics ? 'json' : 'stream' }); if (response.status === 200) { let bodyContent = isAnalytics ? JSON.stringify(response.data) : response.data; await s3.upload({ Bucket: 'my_bucket_name', Key: s3Key, Body: bodyContent }).promise(); return { statusCode: 200, body: `${s3Key} fetched and uploaded successfully` }; } else { await logError({ error: 'API response error', status: response.status, statusText: response.statusText, url }); return { statusCode: response.status, body: response.statusText }; } } catch (error) { await logError({ error: 'Error fetching report', url, details: error }); return { statusCode: 500, body: JSON.stringify(`Error fetching ${s3Key}`) }; } }; exports.handler = async (event) => { const secretName = 'AppStoreConnectPrivateKey'; try { const secretData = await getSecret(secretName); const { keyId, issuerId, private_key: privateKeyPem } = secretData; const token = await getJwtToken(keyId, issuerId, privateKeyPem); const startDate = '2023-09-01'; const endDate = '2024-09-30'; const apiEndpoints = [ { url: `https://api.appstoreconnect.apple.com/v1/analyticsReportRequests`, // Changed to request report s3Key: 'my_folder/my_subfolder/unique_widget_installs.json', isAnalytics: true, body: { "data": { "type": "analyticsReportRequests", "attributes": { "accessType": "ONGOING", "name": "Home Screen Widget Installs", "category": "APP_USAGE" }, "relationships": { "app": { "data": { "type": "apps", "id": "YYYYYYYYYYYY" } } } } } } ]; Returns the following error : { "error": "Error fetching report", "url": "https://api.appstoreconnect.apple.com/v1/analyticsReportRequests", "details": { "message": "Request failed with status code 409", "name": "AxiosError", "stack": "AxiosError: Request failed with status code 409\n at settle (/var/task/node_modules/axios/dist/node/axios.cjs:2019:12)\n at IncomingMessage.handleStreamEnd (/var/task/node_modules/axios/dist/node/axios.cjs:3135:11)\n at IncomingMessage.emit (node:events:531:35)\n at IncomingMessage.emit (node:domain:488:12)\n at endReadableNT (node:internal/streams/readable:1696:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)\n at Axios.request (/var/task/node_modules/axios/dist/node/axios.cjs:4287:41)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async fetchAndUploadReport (/var/task/index.js:68:26)\n at async Promise.all (index 0)\n at async exports.handler (/var/task/index.js:174:25)", "config": { "transitional": { "silentJSONParsing": true, "forcedJSONParsing": true, "clarifyTimeoutError": false }, "adapter": [ "xhr", "http", "fetch" ], "transformRequest": [ null ], "transformResponse": [ null ], "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "maxBodyLength": -1, "env": {}, So I am not sure if the JSON body I am passing this URL endpoint are correct or if this is the correct API to be using to attempt to obtain this information. Please let me know when you have the chance and I look forward to hearing from you.
0
0
93
1w
macos Objective-C openURL failed
error: Error Domain=NSCocoaErrorDomain Code=256 "The application “Google Chrome” could not be launched because a miscellaneous error occurred." UserInfo={NSURL=file:///Applications/Google%20Chrome.app/, NSLocalizedDescription=The application “Google Chrome” could not be launched because a miscellaneous error occurred., NSUnderlyingError=0x6000038376c0 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x6000038349f0 {Error Domain=OSLaunchdErrorDomain Code=112 "Could not find specified domain" UserInfo={NSLocalizedFailureReason=Could not find specified domain}}}}}
1
0
62
1w
How to find renamed app using old name in Spotlight?
We are planning on renaming our app. The new name is not like the current name. It will be renamed in the App Store as well as the App display name. Yet, we still want new and existing users to be able to find the app by using the old name in search/spotlight under iOS. A great example of this is entering Twitter to find the X app and it shows up in the App section in the Spotlight search. Are there any guidelines, settings, or tricks for doing this? Some have suggested adding a Spotlight search term but that will not have it show up in the App section I fear.
1
0
86
1w
Widget Configuration's Selected Parameter Always Reverts to Default
I created an intent for a configurable widget that lets users choose an option for a parameter called "domain." I've successfully loaded the selectable items for this parameter using the following code: import Intents class IntentHandler: INExtension, ConfigChartIntentHandling { func provideDomainOptionsCollection(for intent: ConfigChartIntent) async throws -> INObjectCollection<Domain> { let prefs = UserDefaults(suiteName: "group.name") let domains = prefs?.stringArray(forKey: "domains") if let domains { let optionsCollection = domains.map { Domain(identifier: $0, display: $0) } return INObjectCollection(items: optionsCollection) } else { // If no options, provide an empty list or a default option return INObjectCollection(items: []) } } } The issue occurs when I select a value for the "domain" parameter. Each time I select a value and then reopen the configuration modal, the field reverts back to "Choose." Here's a screenshot illustrating the behavior: Additionally, the widget doesn’t refresh after I change the "domain" value. However, another parameter using an enum ("Stats Type") works as expected. Is there something I might be missing? My Environment: MacOS Sonoma XCode 15.4
0
0
95
1w
Does Live Activity always receive updates for pushToStartTokenUpdates and activityUpdates?
Our context involves smart kitchen appliances, where cooking may be initiated by an app or directly by the device. When the app is not running, we can only start a Live Activity through a remote push notification. However, an increasing number of users report issues where they cannot update or terminate the Live Activity. While we can reproduce this issue in some cases, it is inconsistent and lacks a clear pattern. I have a sample project and would like to confirm the following questions: When the app is not running, does each pushToStartToken update wake the app and reliably trigger the callback below? for await pushToken in Activity<DeviceAttributes>.pushToStartTokenUpdates { } When the app is not running, does each pushTokenUpdates update wake the app and reliably trigger the callback below? Task { for await activity in Activity<DeviceAttributes>.activityUpdates { Task { for try await tokenData in activity.pushTokenUpdates { } } } } Must pushToStartTokenUpdates and pushTokenUpdates be placed directly in application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?), or can they be in another wrapper, such as an RxSwift wrapper? If pushTokenUpdates is updated, but the received pushToken fails to synchronize to the server due to network issues, how should this be handled? Alternatively, if you have any better suggestions, I would be very grateful to hear them. Here is a simple example.
1
0
61
1w
Google admob not working for specific bundle identifier iOS
I'm integrating AdMob rewarded interstitial ads into my live iOS app using CocoaPods and package dependency management. The ads are working fine when I use the bundle identifier com.CreativeCub.ProgrammingHu, but when I use the correct identifier com.CreativeCub.ProgrammingHub, the ads stop working. Here’s what I’ve tried: Verified that the bundle identifier matches across Xcode and AdMob. Double-checked the App ID and Ad Unit ID in the AdMob dashboard for com.CreativeCub.ProgrammingHub. Reinstalled the AdMob SDK using CocoaPods. Attempted to integrate AdMob using Swift Package Manager. Created a test project to rule out potential issues with my existing project. Despite these steps, ads only work when I use the shortened bundle identifier (com.CreativeCub.ProgrammingHu), which is not the correct one. Contacted Google admob support for the same but did not worked Tried running in different MacBook system
2
0
146
1w
iOS App terminates but does not generate Crash Report
The app exits immediately on startup, there is no crash message, and I can't get any valuable diagnostic information. It doesn't even get to the main function. It feels like exit is being called somewhere, and then I used atexit to register the relevant handler. Finally, I found the following stack printout It looks like it's a dynamic linking issue, so what's the best way to troubleshoot it. This problem only occurs in release versions.
1
0
71
1w
iOS Message Filter Extension - deferQueryRequestToNetwork(completion:) error
iOS Message Filter Extension - deferQueryRequestToNetwork(completion:) error I made a test app using the iOS App template and added a target using the Message Filter Extension template which invokes deferQueryRequestToNetwork(completion:) when receiving an SMS. The app and the extension have same "Associated Domains Capabilities" with "messagefilter" pointing to a server which receives query requests and returns proper responses. The extension has the "ILMessageFilterExtensionNetworkURL" key in Info.plist file which specifies the server URL. deferQueryRequestToNetwork(completion:) throws a com.apple.calls.messagefilter error which reads "Extension's containing app (appID ) unauthorized to defer requests to host "
0
0
83
1w
DST, DateEncodingStrategy.iso8601, and UTC Fun
Hello, My code calls a macOS system library which returns Foundation Date properties. I have a program that will run every night, and output the data via the Swift JSONEncoder and uses DateEncodingStrategy.iso8601. As you likely know, a DST shift happened over the weekend here in the US. In my output, every single Date changed by 1 hour, despite the fact that nothing in the underlying data changed overnight. Here is an example diff in the output. I see the "Z", which I think should not be affected by DST changes. - "dateAdded" : "2003-12-15T17:02:56Z", - "dateModified" : "2007-03-07T04:31:16Z", + "dateAdded" : "2003-12-15T18:02:56Z", + "dateModified" : "2007-03-07T05:31:16Z", Here is a sample of the data: public struct Track: Codable, Hashable { var dateAdded: Date? var dateModified: Date? } And the encoding is here: extension Array where Element == Track { public func jsonData() throws -> Data { let encoder = JSONEncoder() encoder.outputFormatting = [.prettyPrinted, .sortedKeys] encoder.dateEncodingStrategy = .iso8601 return try encoder.encode(self) } } Pretty basic stuff overall. So my questions are: Am I correct in my assumption that .iso8601 is UTC, and that UTC is daylight savings shift agnostic? Is this the right way to ensure the my JSON is encoded in UTC? If the library I am calling is building its Date incorrectly, how may I work around the problem? I'm not reporting the library name right now, in order to ensure that my code is doing the right thing without assumptions. Thanks for any tips!
4
0
144
1w
INPlayMediaIntentHandling, Unable to Trigger App to Play Specific Podcast
I have an app that's capable of playing podcasts via Siri requests, e.g. "Hey Siri, play [Podcast Name]". I’m using INPlayMediaIntentHandling, that is, the SiriKit domain intents, as opposed to the newer AppIntents framework for its ability to select my app for audio playback without the need to specify the name of the app in the user's request to Siri. This works great overall for the many podcasts I’ve tested the app with, with the exception of one. There's a podcast called "The Headlines", and I when I test the app with the request "Hey Siri, play The Headlines", my app is never selected. Instead, Apple Podcasts begins playback of a show called "NPR News Now". Oddly, if the Apple Podcasts app is deleted, my app will still not be selected by the system, and instead, Siri responds with "I don’t see an app for that. You’ll need to download one" with a button to open the App Store. Additionally, if I do add the app name to the request using this style of intent, Siri responds with "[App Name] hasn’t added support for that with Siri." However, I’d still like to accomplish this without requiring the app name in the Siri request. There's nothing complex in my setup: The target declares one supported intent, INPlayMediaIntent, with "Podcasts" selected as a supported media category. The Siri entitlement is enabled. My INSiriAuthorizationStatus is .authorized. My intent handler is specified in my AppDelegate as follows: func application(_ application: UIApplication, handlerFor intent: INIntent) -> Any? { return IntentHandler.shared } My intent handler is simple: final class IntentHandler: NSObject, INPlayMediaIntentHandling { static let shared = IntentHandler() func handle(intent: INPlayMediaIntent) async -> INPlayMediaIntentResponse { print("IntentHandler: processing intent: \(intent)") /** code to start playback based on information found in `intent` **/ } When requesting Siri to "Play The Headlines", my handler code is not called at all. For all other supported shows, the print statement executes, and playback begins as expected. Is there any way I can get my app to be selected instead of Apple Podcasts for this request?
1
0
112
1w
Issue with Siri Not Displaying Prompt in App Intent
Hello everyone, I'm currently working on an App Intent for my iOS app, and I’ve encountered a frustrating issue related to how Siri prompts for a category selection. Here’s an overview of what I’m dealing with: extension Category: AppEntity, @unchecked Sendable { var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(name)") } static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Category") typealias DefaultQueryType = ShortcutsCategoryQuery static var defaultQuery: ShortcutsCategoryQuery = ShortcutsCategoryQuery() } struct ShortcutsCategoryQuery: EntityQuery { func entities(for identifiers: [String]) async throws -> [Category] { let context = await ModelContext(sharedModelContainer) let categories = try CategoryDataProvider(context: context).getItems() return categories.filter { identifiers.contains($0.id) } } func entities(matching string: String) async throws -> [Category] { return try await suggestedEntities() } func suggestedEntities() async throws -> [Category] { let context = await ModelContext(sharedModelContainer) do { let categories = try CategoryDataProvider(context: context).getItems() if categories.isEmpty { print("No categories found.") } return categories.map { category in Category( id: category.id, name: category.name, stringSymbol: category.stringSymbol, symbol: category.symbol, stringColor: category.stringColor, color: category.color ) } } catch { print(error) return [] } } } The issue arises when I use Siri to invoke the intent. Siri correctly asks me to select a category but does not display any options unless I said something that Siri recognized, like "Casa(House) or *****(Test)" in portuguese. Only then does it show the list of available categories. I would like the categories to appear immediately when Siri asks for a selection. I've already tried refining the ShortcutsCategoryQuery and debugging various parts of my code, but nothing seems to fix this behavior.
1
0
168
1w
App unexpectedly crashes after installation from testflight
I've an app running for some time in the Appstore now. Recently I had to renew my singing certficicates to be able to publish my app again. I renewed the certificates, updated my provisioning profile and signed a new app version to publish only to find out that the app crashes during the splash screen. I added new features to the app so my first thought was that there would be an issue there. To test that, I built the latest stable version of the app and signed it with the new profivisioning profile. The result was exactly the same crash as the new build. My assumption is that the crash is caused by bad signing (?) but I am not sure because I'm lacking experience on that front. I do have a crash report from testflight and logs from the device where the app crashed. Testflight crash: TestFlight crashlog Device error logs: Device error logs Hope someone can help my out because I'm at a dead end :(
1
0
140
1w
How to force update data from child phone ? FamilyControls / Screen Time Api / DeviceActivity
The data displayed about a child’s apps can be outdated (DeviceActivityReport), leading to misinformation for the user. When I access the “Screen Time” section (for child in the parent device) in the iPhone settings, I see there is an update functionality to force load the actual data. I have tried various workarounds, such as attempting to force an update on the child’s device to call DeviceActivityReport and opening system settings, but none of these have been successful :( How can I implement something similar? Is there a way to force update this data ?
0
2
148
2w
iPhone mirroring screen switching (request & question)
iPhone mirroring is available from macOS 15. When running an app with iPhone mirroring Can I know whether the app currently being mirrored is running at the top of the Mac app or screen? Or is there a way to know whether it is hidden by another app on the Mac or re-displayed? If not, I hope it will be added in a future update. And I hope there is an API that can tell whether the current app is connected to iPhone mirroring or not.
0
0
120
2w