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.

Posts under General subtopic

Post

Replies

Boosts

Views

Activity

Evidently I'm not generating API tokens right.
I'm trying (in Swift) to use CryptoKit to generate the required JWT for the Apple Music Web API, as documented (sort of) here. But I'm getting 401s no matter what I try. I found some examples of generating JWTs online, but something isn't working here. I've set up my identifiers and gotten an API secret through my account in the dev portal. It's associated with an identifier requesting Music API access (I requested all three available Music-related capabilities). For the secret, I'm using the long key string from the .p8 file I generated and downloaded from the dev portal. Here's what I've tried: struct APIToken { struct Header: Encodable { let alg = "HS256" let kid: String } struct Payload: Encodable { let iss: String let iat: String let exp: String } static func tokenize(keyID: String, issuerID: String, secret: String) -> String { let privateKey = SymmetricKey(data: Data(secret.utf8)) let headerJSONData = try! JSONEncoder().encode(Header(kid: keyID)) let headerBase64String = headerJSONData.base64EncodedString() let currUnixTime = Int(Date().timeIntervalSince1970) let expUnixTime = currUnixTime + 5 * 2628288 // five months of seconds let payloadJSONData = try! JSONEncoder().encode(Payload(iss: issuerID, iat: "\(currUnixTime)", exp: "\(expUnixTime)")) let payloadBase64String = payloadJSONData.base64EncodedString() let toSign = Data((headerBase64String + "." + payloadBase64String).utf8) let signature = HMAC<SHA256>.authenticationCode(for: toSign, using: privateKey) let signatureBase64String = Data(signature).base64EncodedString() let token = [headerBase64String, payloadBase64String, signatureBase64String].joined(separator: ".") print(token) return token } } I also tried making sure the base64 strings are URL-safe with this extension: extension Data { func URLSafeBase64EncodedString() -> String { return base64EncodedString() .replacingOccurrences(of: "+", with: "-") .replacingOccurrences(of: "/", with: "_") .replacingOccurrences(of: "=", with: "") } } but that made no difference. All the documentation says is A decoded developer token has the following format. { "alg": "ES256", "kid": "ABC123DEFG" } { "iss": "DEF123GHIJ", "iat": 1437179036, "exp": 1493298100 } After you create the token, sign it with your MusicKit private key using the ES256 algorithm. Am I not doing that? Any insight appreciated.
0
0
454
Nov ’24
Transfer sub is different length
Hello. I'm preparing transfer app now but don't understand identifier length. reporence : https://developer.apple.com/documentation/sign_in_with_apple/transferring_your_apps_and_users_to_another_team 1 : xxxxxx.15fbexc6b31e41e78b891803a56b1axx.0247 2: xxxxxx.26ae9x5347f1f4fcebb3ae1b91807b5xx number 1 is The team-scoped user identifier number 2 is transfer identifier but length is different so i scared is it okay?
0
0
115
Dec ’24
MacOS Sequoia install error
Good day. Installed Sequoia Developer Beta. After that, the laptop started to behave incorrectly, programs over 1 GB stopped installing, updates were not installed, sometimes it rebooted spontaneously. Decided to roll back. With the help of another Macbook, I managed to install 14.6.1. Errors remained. Updates are not installed. Tried to restore through the recovery menu, error at 52 minutes, using a boot disk, the same error. What else can I do? Mac Book Pro M1 16gb/2tb
0
0
305
Dec ’24
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
354
Nov ’24
Optimize watchOS CMSensorDataList parsing
I am trying to parse CMSensorDataList in watchOS. The maximum batch of data is comprised of 30 minutes. The sampling rate is 50Hz, which makes it 90,000 records for 30 minutes. We iterate over each item and finally write the data to a CSV file. As this is a slow processing keeping in view the execution limits of watchOS, the process suspends when app goes to the background. This way, it takes too much time to parse a significant time data. My question is, is there a way we can serialize this CMSensorDataList as a whole and transfer it to the phone using WCSession? Or is there another effective way to achieve this?
0
0
389
Oct ’24
How to reset system window private picker alert with Screen Capture Kit
Hi, I would like to reset system window private picker alert with ScreenCapture kit. i can reset the ScreenCapture permission with tccutil reset ScreenCapture. but it does not reset the system window private picker alert. i tried deleting the application directory from container and it does not help. the system window private picker alert uses the old approval i gave and it does not prompt a new alert. How can i starta with fresh screencapture kit settings for an app in testing? Thanks
0
0
78
Jun ’25
Problems with Widget buttons not getting pressed
So I have a button on a widget styled as seen below. I want this button to take up the entirety of the width, problem is, when it does so either using a frame(maxWidth: .infinity) or if I increase the horizontal padding, the button still only gets clicked if the user taps near the buttons center. Otherwise, it will open the app. Relevant code: Button(intent: Intent_StartRest() ){ Text("stop") } .buttonStyle(PlainButtonStyle()) .tint(.clear) .padding(.vertical, 6) .padding(.horizontal, 100) .background(RoundedRectangle(cornerRadius: 30).fill(.button)) .foregroundStyle(.buttonText) // Just sets text color .useAppFont(size: 18, relativeTo: .caption, weight: .bold) // Just sets font Any pointers?
0
0
341
Nov ’24
iTunes api lookup by isbn
Hello, I have a question related to the public iTunes Search API: https://performance-partners.apple.com/search-api Do all the books have an ISBN associated? I used to do queries like: https://itunes.apple.com/lookup?isbn=9781501110368. That book is available on Apple Books here: https://books.apple.com/us/book/it-ends-with-us/id1052928247 and the endpoint above returns informations about it. However for newer books like: https://itunes.apple.com/lookup?isbn=9781419766954 https://itunes.apple.com/lookup?isbn=9781250288776 Nothing comes back anymore even if those books exist there. The url's for the 2 above are: https://books.apple.com/us/book/hot-mess-diary-of-a-wimpy-kid-19/id6476554491 https://books.apple.com/mt/book/the-mirror/id6474420363 For newer books starting the beginning of September 2024, nothing seems to come back when you search them by ISBN. Thanks
0
0
433
Dec ’24
Pencilkit custom pen
I want to create a brush similar to a fountain pen, with a three-dimensional feel to the strokes and a distinct tip. Alternatively, is it possible to achieve this by modifying the configuration parameters of a fountain pen brush?
0
0
34
Mar ’25
FamilyActivityPicker: manage own device AND children device
Hello, I am unable to figure out how I tell the FamilyActivityPicker whether it should show apps installed on my personal device (to be used with AuthorizationCenter.shared.requestAuthorization(for: .individual)) or apps installed on my child’s device (authenticated their phone via AuthorizationCenter.shared.requestAuthorization(for: .child)). Is there any parameter or SwiftUI modifier I need to apply? Otherwise, how does the user or the app know which token belongs to them and which token belongs to their child’s device? Radar: FB17020977 Thanks a lot for your help!
0
0
62
Mar ’25
How to uninstall/delete Voice Control on macOS?
How to uninstall/delete Voice Control on macOS so that I can test my app for the case when the initial use of Voice Control causes it to be downloaded from Apple? Is there a folder in the macOS System or Library to delete to force a re-download of Voice Control? My macOS app uses the older NSSpeechRecognizer to handle speech commands, but to use NSSpeechRecognizer required authorization via [SFSpeechRecognizer requestAuthorization...]. I do this and on a macOS system it can trigger a download of Voice Control, the macOS feature. An alert appears with: "A 390 MB download is required to use speech recognition features in MyApp. You may need to quit and open MyApp again after download completes."
0
0
320
Jan ’25