Apple Music API

RSS for tag

Apple Music API integrates streaming music with Apple Music content.

Posts under Apple Music API tag

200 Posts

Post

Replies

Boosts

Views

Activity

Apple Music not showing up
I have two apple ID's. On my iPhone (16.x) I have Apple Music on with no issues. On the beta I am not given a choice of adding another Apple ID for Apple Music. In Settings go to Apple ID and tap on Subscriptions. I only see the current Apple ID using the OS-17 beta release Has anyone seen this?
0
0
501
Jul ’23
Is it possible to have Music on the app not from Itunes or the Music Kit?
Planning to create a Music Game App similar to Guitar Hero kind of, and I am planning to use songs from beginner producers (They don't have any Publishers or Distributors). If I get their legal concent through a contract to use their songs, does Apple allow to have Music that is not from Itunes if I get the legal license from the producer to use their songs in my app? Will apple allow songs that don't have Publishers or Distributors, or in the App review stage they will flag it and cause an issue for me?
0
0
619
Jul ’23
"Add to Favorites" on Apple Music API
Is there any way to make an API call that would add an artist to a user's favorites, like this article outlines? https://support.apple.com/guide/music/select-artists-as-favorites-musf33a29ebf/mac I know I am able to add individual resources (song, album, playlists) to user libraries but I specifically want to add a favorite artist. Thank you in advance to anybody with thoughts.
1
0
790
Jul ’23
Language Setting for Music App
Hello. I'm Korean, and the system language of macOS is in English because user directories such as Desktop and Document should be displayed in English. As I use the system language in English, the singers and song names of the Korean songs of Apple Music are also displayed in English. It is so confused to find the song in the App, or to talk about the song with other people. I'm using Apple Music with my Korean account, and I'm also using the region of the system in Korea. There is a function to customize language settings for the specific applications, so I tried to change the language setting of the Music App (specific app) to Korean. In this case, Music Apps are displayed in Korean. But the song information (singer, title) and various playlists are still displayed in English. Many Korean users are suffered with this problem, so I think there should be some ways to see the information of Korean music sources in Korean in the Music App preferences, other than changing the system language of macOS and iOS.
1
6
2.3k
Jul ’23
Apple Music API: only get full Albums from user's library
If a user has only added one song from an album in its library, the library album endpoint (/me/library/albums) will return this album. It does not make sense because the user did not add the full album to its library, only one song. Note that the Apple Music app is doing the same in its Library > Albums section. How to retrieve only those albums which have been added ?
0
0
770
Jul ’23
User login flow with nodeJS
Hi everyone. I am creating a ReactNative application which requires user's data from his/her apple music account. In order to retrieve user's apple music data, I understand that I need both a developer token and a user's access token with the appropriate scope for Apple Music. https://developer.apple.com/documentation/applemusicapi/user_authentication_for_musickit I had created developer token and tested it, suggested by documentation https://developer.apple.com/documentation/applemusicapi/generating_developer_tokens For user's login, I am creating login URL with the npm package apple-auth and configuration object is export const con: any = { client_id: clientId, team_id: teamId, key_id: keyId, redirect_uri: "https://api.borrow4less.ca/api/v1/welcome", scope: "email", }; I registered a service identifier for domain/subdomain and returnURL. when I go the login url it shows login url is :https://appleid.apple.com/auth/authorize?response_type=code%20id_token&client_id=com.QueueMusic&redirect_uri=https://api.borrow4less.ca/api/v1/welcome&state=489612589c&scope=email&response_mode=form_post Invalid client id or web redirect url. I would greatly appreciate any guidance or insights from the community regarding the correct configuration object to use with "apple-auth" or any alternative. Regards
0
0
1.2k
Jul ’23
Determining song availability based on user's region or country in MusicKit
I'm currently working on integrating MusicKit into my app and would like to provide a seamless user experience by displaying only the songs that are available in the user's region or country. However, after going through the MusicKit documentation, I couldn't find a direct method to determine song availability based on the user's location. I wanted to inquire if there is a way to determine if a specific song or a catalog of songs is available in the user's region or country using MusicKit. It would be incredibly helpful if someone could guide me on how to achieve this or provide any insights on alternative approaches. Thank you in advance for your assistance!
0
0
584
Jul ’23
[Apple Music API] How can i control Music User Token expiration time?
Hello there! I have a problem: when i create Music User Token via AppleMusicKit, it returns me token that expires after one or two days. But regarding to this threads - https://developer.apple.com/forums/thread/654814 https://developer.apple.com/forums/thread/685343 it should expire in 6 months! Do I need to consider something when creating a token so that its lifetime will be 6 months and not 2 days? Maybe something with developer token or with MusicKit? Maybe something in apple account? p.s. i tried to find solution of this problem in internet and noticed that many other people have such problem too. And no one got any answers expect that token should live 6 months.
5
3
2.2k
Jul ’23
List of Genre IDs?
Hey All I've been looking at adding a visual representation of the song's first genre in my app and therefor was wondering if there's a list available somewhere of all the Genre's available in MusicKit and their IDs e.g. Genre(id: "21", name: "Rock", parent: Genre(id: "34", name: "Music")) So my questions: Is there a list of all IDs? Are these IDs the same in every country? The reason why I would want this is to have my visuals be safe for localization. For example: If I'd call my asset icon-electronic and then localize my app in dutch it would ask for icon-electronisch. I hope this makes sense and I hope I don't have to browse and save a list of all Genre's by hand haha
4
0
3k
Jun ’23
Error while using music catalog search request
I am attempting to use MusicCatalogSearchRequest(.isrc) in order to search the catalog for info related to a song by ISRC. Issue is I get HUGE amounts of debug output in the console with the errors below. The clutter the Xcode logs to the point where I can't even view anything useful. Has anyone else seen this? Attempted to register account monitor for types client is not authorized to access: {( "com.apple.account.iTunesStore" )}
1
3
950
Jun ’23
Getting error code while integrating the rest api with my machine code 8336324201 , 08336324201
Hey i am trying to integrate my api with my machine for some testing work but it is showing me an error code possibility combinations 18336324201 , 08336324201 , 8336324201 , Can anyone help me out fixing this i have been working really hard for this project
0
0
782
Jun ’23
Apple Music API Enhancements
Hi, We are a funded startup developing a music festival and concert application that integrates with Apple Music. Two big features the API is missing are PUT and DELETE endpoints for tracks on a playlist. Both of these would drastically enhance the user experience on third-party apps that leverage Apple Music, specifically for editing and curating playlists. We have also noticed many errors returned as 403 when we have literally just signed in with a brand new token. We have confirmed on our end that the token is valid, fresh and can be used through other clients. As well, Apple's MusicKitJS SDK could use a bit of work. We were able to unminify and work around these issues; most of them were addressed with a simple try/catch and retry routine. We love the Apple Music API and SDK, and in general found it super easy to integrate with, setup and use. We also firmly believe Apple puts out superior products to other technology firms in the same industry. It was disappointing to see the API and SDK for Apple Music falling behind compared to other music providers who offer similar API's. We really hope Apple improves and enhances these offerings in the future. Also just wanted to give a shotout and thanks to all of the devs who make these services accessible and the integration possible. We wouldn't be here without you, and didn't want this post to come off as a rant just more of a friendly "nudge."
0
0
1.1k
Jun ’23
unauthorized request in integration with Apple Music API
Hello Apple Developer community, I'm currently facing an issue with the integration of the Apple Music API in my application. I've followed the documentation and guidelines provided by Apple, but I'm encountering problems with authentication and parsing the Apple Music track details. Here's a summary of the issue: When making a request to fetch Apple Music track details using the provided API endpoint, I'm receiving the following error: "Error parsing Apple Music track details: The data couldn't be read because it isn't in the correct format." Additionally, the response status code is 401, indicating an unauthorized request. I have already tried the following troubleshooting steps: Verified that the MusicKit App Service is enabled in my app's App ID configuration. Confirmed that the bundle identifier used in the app matches the one in the App ID configuration. Ensured that I'm signed in with a valid Apple ID in the simulator and device I'm testing. Despite these efforts, the issue persists. I believe I have followed the correct procedures for automatic developer token generation, but there might be something missing or misconfigured. I'm seeking assistance and guidance from the Stack Overflow community on how to resolve this issue. Any insights, suggestions, or troubleshooting steps would be greatly appreciated. Thank you in advance for your help! func fetchAppleMusicTrackDetails(from mediaURL: URL, completion: @escaping (AppleMusicTrack?) -> Void) { let components = URLComponents(url: mediaURL, resolvingAgainstBaseURL: false) guard let itemID = components?.queryItems?.first(where: { $0.name == "id" })?.value else { completion(nil) return } fetchStorefront { storefront in guard let storefront = storefront else { print("storefront issue") completion(nil) return } let regex = try! NSRegularExpression(pattern: "\\s*\\(.*?\\)\\s*", options: .caseInsensitive) let trimmedStorefront = regex.stringByReplacingMatches(in: storefront, options: [], range: NSMakeRange(0, storefront.count), withTemplate: "") let encodedStorefront = trimmedStorefront.replacingOccurrences(of: " ", with: "%20") let lookupURLString = "https://api.music.apple.com/v1/catalog/\(encodedStorefront)/songs/\(itemID)" print(lookupURLString) guard let lookupURL = URL(string: lookupURLString) else { print("lookupURL issue") completion(nil) return } URLSession.shared.dataTask(with: lookupURL) { (data, response, error) in if let httpResponse = response as? HTTPURLResponse { print("Status code: \(httpResponse.statusCode)") } if let error = error { print("Error fetching Apple Music track details: \(error.localizedDescription)") completion(nil) return } guard let data = data else { completion(nil) print("no data") return } let responseString = String(data: data, encoding: .utf8) print("Response data: \(responseString ?? "No data")") do { let responseJSON = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] let results = responseJSON?["results"] as? [[String: Any]] let trackData = results?.first print(responseJSON) // Extract the necessary track information from the JSON response guard let title = trackData?["trackName"] as? String, let artist = trackData?["artistName"] as? String, let album = trackData?["collectionName"] as? String, let artworkURLString = trackData?["artworkUrl100"] as? String, let artworkURL = URL(string: artworkURLString), let trackURLString = trackData?["previewUrl"] as? String, let trackURL = URL(string: trackURLString) else { completion(nil) return } // Download the artwork image URLSession.shared.dataTask(with: artworkURL) { (artworkData, _, _) in guard let artworkData = artworkData, let artworkImage = UIImage(data: artworkData) else { completion(nil) return } let track = AppleMusicTrack(title: title, artist: artist, album: album, artwork: artworkImage, trackURL: trackURL) completion(track) }.resume() } catch { print("Error parsing Apple Music track details: \(error.localizedDescription)") completion(nil) } }.resume() } } func fetchStorefront(completion: @escaping (String?) -> Void) { SKCloudServiceController().requestStorefrontCountryCode { storefrontCountryCode, error in if let error = error { print("Error fetching storefront country code: \(error.localizedDescription)") completion(nil) return } guard let countryCode = storefrontCountryCode else { print("country code error") completion(nil) return } completion(countryCode) } }
0
0
962
May ’23
MPMediaLibrary.default().addItem broken in macOS 13.4 / Catalyst
The following line of code worked fine in macOS 13.3 / Catalyst: try await MPMediaLibrary.default().addItem(withProductID: "1678639572") Since the 13.4 update it now throws an error: The operation couldn’t be completed. (MPErrorDomain error 11.) Although the Apple Music track with catalog Id 1678639572 does seem to get added to the library regardless. MPError.errorCode 11 is an undocumented value. Can someone please advise what error code 11 actually means, and if there's a workaround? I've raised this as feedback id FB12196635.
0
0
1k
May ’23
Catalog relationships empty for /me/library/albums. How to reconcile ?
For some library records, the catalog relationships is empty in the response to request: /v1/me/library/albums?include=catalog The json will look like that: "catalog": { "href": "/v1/me/library/albums/l.mbhaBBs/catalog", "data": [] } The catalog relationship url (/v1/me/library/albums/l.mbhaBBs/catalog) will give: { "errors": [ { "id": "YS7BUVCTXA3QWDVX3YQQSCPEUY", "title": "No related resources", "detail": "No related resources found for catalog", "status": "404", "code": "40403" } ] } I am talking about an album that was added from the catalog in the first place. When it happens, removing the album from the library and adding it again using the Apple Music app, resolves the issue. Is there another way to force the library-album to reconcile with the catalog-album using the API itself ?
1
0
837
May ’23
403 Error using userToken generated by MusicKit
I'm developing a flutter app and using https://pub.dev/packages/music_kit to leverage MusicKit to handle the initial user permission request and generating the userToken. I then need to make requests to the Apple Music API from my server through a background task to retrieve the user's heavy rotation information which is used to recommend events. The initial authorization works as expected and generates a developer token and user token, but when I use the developer token and user token in a get request to https://api.music.apple.com/v1/me/storefront it returns a 403 error "Invalid authentication". I can't seem to figure out what's causing this as I'm using the user token generated from MusicKit, I also test the developer token and it works on non-user specific api end points, so it's a correct developer token. Are user tokens generated by the MusicKit swift code only able to be used in MusicKit calls in the app? Also when making a status request through MusicKit I get "MusicAuthorizationStatus.authorized(musicUserToken: null)" which seems strange as I would assume the token that's returned would be included in the status if it's including the parameter musicUserToken. The account being connected is on a 1 month free trial at the moment if that makes a difference.
0
1
780
May ’23
Apple Music not showing up
I have two apple ID's. On my iPhone (16.x) I have Apple Music on with no issues. On the beta I am not given a choice of adding another Apple ID for Apple Music. In Settings go to Apple ID and tap on Subscriptions. I only see the current Apple ID using the OS-17 beta release Has anyone seen this?
Replies
0
Boosts
0
Views
501
Activity
Jul ’23
Is it possible to have Music on the app not from Itunes or the Music Kit?
Planning to create a Music Game App similar to Guitar Hero kind of, and I am planning to use songs from beginner producers (They don't have any Publishers or Distributors). If I get their legal concent through a contract to use their songs, does Apple allow to have Music that is not from Itunes if I get the legal license from the producer to use their songs in my app? Will apple allow songs that don't have Publishers or Distributors, or in the App review stage they will flag it and cause an issue for me?
Replies
0
Boosts
0
Views
619
Activity
Jul ’23
"Add to Favorites" on Apple Music API
Is there any way to make an API call that would add an artist to a user's favorites, like this article outlines? https://support.apple.com/guide/music/select-artists-as-favorites-musf33a29ebf/mac I know I am able to add individual resources (song, album, playlists) to user libraries but I specifically want to add a favorite artist. Thank you in advance to anybody with thoughts.
Replies
1
Boosts
0
Views
790
Activity
Jul ’23
Language Setting for Music App
Hello. I'm Korean, and the system language of macOS is in English because user directories such as Desktop and Document should be displayed in English. As I use the system language in English, the singers and song names of the Korean songs of Apple Music are also displayed in English. It is so confused to find the song in the App, or to talk about the song with other people. I'm using Apple Music with my Korean account, and I'm also using the region of the system in Korea. There is a function to customize language settings for the specific applications, so I tried to change the language setting of the Music App (specific app) to Korean. In this case, Music Apps are displayed in Korean. But the song information (singer, title) and various playlists are still displayed in English. Many Korean users are suffered with this problem, so I think there should be some ways to see the information of Korean music sources in Korean in the Music App preferences, other than changing the system language of macOS and iOS.
Replies
1
Boosts
6
Views
2.3k
Activity
Jul ’23
Apple Music API: only get full Albums from user's library
If a user has only added one song from an album in its library, the library album endpoint (/me/library/albums) will return this album. It does not make sense because the user did not add the full album to its library, only one song. Note that the Apple Music app is doing the same in its Library > Albums section. How to retrieve only those albums which have been added ?
Replies
0
Boosts
0
Views
770
Activity
Jul ’23
User login flow with nodeJS
Hi everyone. I am creating a ReactNative application which requires user's data from his/her apple music account. In order to retrieve user's apple music data, I understand that I need both a developer token and a user's access token with the appropriate scope for Apple Music. https://developer.apple.com/documentation/applemusicapi/user_authentication_for_musickit I had created developer token and tested it, suggested by documentation https://developer.apple.com/documentation/applemusicapi/generating_developer_tokens For user's login, I am creating login URL with the npm package apple-auth and configuration object is export const con: any = { client_id: clientId, team_id: teamId, key_id: keyId, redirect_uri: "https://api.borrow4less.ca/api/v1/welcome", scope: "email", }; I registered a service identifier for domain/subdomain and returnURL. when I go the login url it shows login url is :https://appleid.apple.com/auth/authorize?response_type=code%20id_token&client_id=com.QueueMusic&redirect_uri=https://api.borrow4less.ca/api/v1/welcome&state=489612589c&scope=email&response_mode=form_post Invalid client id or web redirect url. I would greatly appreciate any guidance or insights from the community regarding the correct configuration object to use with "apple-auth" or any alternative. Regards
Replies
0
Boosts
0
Views
1.2k
Activity
Jul ’23
Determining song availability based on user's region or country in MusicKit
I'm currently working on integrating MusicKit into my app and would like to provide a seamless user experience by displaying only the songs that are available in the user's region or country. However, after going through the MusicKit documentation, I couldn't find a direct method to determine song availability based on the user's location. I wanted to inquire if there is a way to determine if a specific song or a catalog of songs is available in the user's region or country using MusicKit. It would be incredibly helpful if someone could guide me on how to achieve this or provide any insights on alternative approaches. Thank you in advance for your assistance!
Replies
0
Boosts
0
Views
584
Activity
Jul ’23
Amazon Chime SDK for iOS : Building video calling, audio calling, and screen sharing applications powered by Amazon Chime but it says Error code : 8884098604
Amazon Chime SDK for iOS: Building video calling, audio calling, and screen sharing applications powered by Amazon Chime but it says Error code : 8884098604 Can anyone help me with this
Replies
0
Boosts
0
Views
588
Activity
Jul ’23
[Apple Music API] How can i control Music User Token expiration time?
Hello there! I have a problem: when i create Music User Token via AppleMusicKit, it returns me token that expires after one or two days. But regarding to this threads - https://developer.apple.com/forums/thread/654814 https://developer.apple.com/forums/thread/685343 it should expire in 6 months! Do I need to consider something when creating a token so that its lifetime will be 6 months and not 2 days? Maybe something with developer token or with MusicKit? Maybe something in apple account? p.s. i tried to find solution of this problem in internet and noticed that many other people have such problem too. And no one got any answers expect that token should live 6 months.
Replies
5
Boosts
3
Views
2.2k
Activity
Jul ’23
How to Resolve Error 8889275382 Loading Apple Credentials from File in Amazon SNS
How to Resolve Error 8889275382 Loading Apple Credentials from File in Amazon SNS ? Errors: 8889275382 , 18889275382 It always throws 2 possible error codes .
Replies
0
Boosts
0
Views
845
Activity
Jun ’23
List of Genre IDs?
Hey All I've been looking at adding a visual representation of the song's first genre in my app and therefor was wondering if there's a list available somewhere of all the Genre's available in MusicKit and their IDs e.g. Genre(id: "21", name: "Rock", parent: Genre(id: "34", name: "Music")) So my questions: Is there a list of all IDs? Are these IDs the same in every country? The reason why I would want this is to have my visuals be safe for localization. For example: If I'd call my asset icon-electronic and then localize my app in dutch it would ask for icon-electronisch. I hope this makes sense and I hope I don't have to browse and save a list of all Genre's by hand haha
Replies
4
Boosts
0
Views
3k
Activity
Jun ’23
canBecomeSubscriber for Apple Music incorrectly returns false
Hi, It seems canBecomeSubscriber of MusicSubscription returns false even if the user is eligible for a subsciption, unless the user has authorized to access his music library. Is that correct? It's kind of a shame, but I guess there's some logic to it.
Replies
0
Boosts
0
Views
976
Activity
Jun ’23
Error while using music catalog search request
I am attempting to use MusicCatalogSearchRequest(.isrc) in order to search the catalog for info related to a song by ISRC. Issue is I get HUGE amounts of debug output in the console with the errors below. The clutter the Xcode logs to the point where I can't even view anything useful. Has anyone else seen this? Attempted to register account monitor for types client is not authorized to access: {( "com.apple.account.iTunesStore" )}
Replies
1
Boosts
3
Views
950
Activity
Jun ’23
Getting error code while integrating the rest api with my machine code 8336324201 , 08336324201
Hey i am trying to integrate my api with my machine for some testing work but it is showing me an error code possibility combinations 18336324201 , 08336324201 , 8336324201 , Can anyone help me out fixing this i have been working really hard for this project
Replies
0
Boosts
0
Views
782
Activity
Jun ’23
Apple Music API Enhancements
Hi, We are a funded startup developing a music festival and concert application that integrates with Apple Music. Two big features the API is missing are PUT and DELETE endpoints for tracks on a playlist. Both of these would drastically enhance the user experience on third-party apps that leverage Apple Music, specifically for editing and curating playlists. We have also noticed many errors returned as 403 when we have literally just signed in with a brand new token. We have confirmed on our end that the token is valid, fresh and can be used through other clients. As well, Apple's MusicKitJS SDK could use a bit of work. We were able to unminify and work around these issues; most of them were addressed with a simple try/catch and retry routine. We love the Apple Music API and SDK, and in general found it super easy to integrate with, setup and use. We also firmly believe Apple puts out superior products to other technology firms in the same industry. It was disappointing to see the API and SDK for Apple Music falling behind compared to other music providers who offer similar API's. We really hope Apple improves and enhances these offerings in the future. Also just wanted to give a shotout and thanks to all of the devs who make these services accessible and the integration possible. We wouldn't be here without you, and didn't want this post to come off as a rant just more of a friendly "nudge."
Replies
0
Boosts
0
Views
1.1k
Activity
Jun ’23
Getting error code while integrating the rest api with my machine code 8336326964 , 08336326964 ,
Hey i am trying to integrate my api with my machine for some testing work but it is showing me an error code possibility combinations 18336326964 , 08336326964 , 8336326964 , Can anyone help me out fixing this i have been working really hard for this project
Replies
0
Boosts
0
Views
707
Activity
Jun ’23
unauthorized request in integration with Apple Music API
Hello Apple Developer community, I'm currently facing an issue with the integration of the Apple Music API in my application. I've followed the documentation and guidelines provided by Apple, but I'm encountering problems with authentication and parsing the Apple Music track details. Here's a summary of the issue: When making a request to fetch Apple Music track details using the provided API endpoint, I'm receiving the following error: "Error parsing Apple Music track details: The data couldn't be read because it isn't in the correct format." Additionally, the response status code is 401, indicating an unauthorized request. I have already tried the following troubleshooting steps: Verified that the MusicKit App Service is enabled in my app's App ID configuration. Confirmed that the bundle identifier used in the app matches the one in the App ID configuration. Ensured that I'm signed in with a valid Apple ID in the simulator and device I'm testing. Despite these efforts, the issue persists. I believe I have followed the correct procedures for automatic developer token generation, but there might be something missing or misconfigured. I'm seeking assistance and guidance from the Stack Overflow community on how to resolve this issue. Any insights, suggestions, or troubleshooting steps would be greatly appreciated. Thank you in advance for your help! func fetchAppleMusicTrackDetails(from mediaURL: URL, completion: @escaping (AppleMusicTrack?) -> Void) { let components = URLComponents(url: mediaURL, resolvingAgainstBaseURL: false) guard let itemID = components?.queryItems?.first(where: { $0.name == "id" })?.value else { completion(nil) return } fetchStorefront { storefront in guard let storefront = storefront else { print("storefront issue") completion(nil) return } let regex = try! NSRegularExpression(pattern: "\\s*\\(.*?\\)\\s*", options: .caseInsensitive) let trimmedStorefront = regex.stringByReplacingMatches(in: storefront, options: [], range: NSMakeRange(0, storefront.count), withTemplate: "") let encodedStorefront = trimmedStorefront.replacingOccurrences(of: " ", with: "%20") let lookupURLString = "https://api.music.apple.com/v1/catalog/\(encodedStorefront)/songs/\(itemID)" print(lookupURLString) guard let lookupURL = URL(string: lookupURLString) else { print("lookupURL issue") completion(nil) return } URLSession.shared.dataTask(with: lookupURL) { (data, response, error) in if let httpResponse = response as? HTTPURLResponse { print("Status code: \(httpResponse.statusCode)") } if let error = error { print("Error fetching Apple Music track details: \(error.localizedDescription)") completion(nil) return } guard let data = data else { completion(nil) print("no data") return } let responseString = String(data: data, encoding: .utf8) print("Response data: \(responseString ?? "No data")") do { let responseJSON = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] let results = responseJSON?["results"] as? [[String: Any]] let trackData = results?.first print(responseJSON) // Extract the necessary track information from the JSON response guard let title = trackData?["trackName"] as? String, let artist = trackData?["artistName"] as? String, let album = trackData?["collectionName"] as? String, let artworkURLString = trackData?["artworkUrl100"] as? String, let artworkURL = URL(string: artworkURLString), let trackURLString = trackData?["previewUrl"] as? String, let trackURL = URL(string: trackURLString) else { completion(nil) return } // Download the artwork image URLSession.shared.dataTask(with: artworkURL) { (artworkData, _, _) in guard let artworkData = artworkData, let artworkImage = UIImage(data: artworkData) else { completion(nil) return } let track = AppleMusicTrack(title: title, artist: artist, album: album, artwork: artworkImage, trackURL: trackURL) completion(track) }.resume() } catch { print("Error parsing Apple Music track details: \(error.localizedDescription)") completion(nil) } }.resume() } } func fetchStorefront(completion: @escaping (String?) -> Void) { SKCloudServiceController().requestStorefrontCountryCode { storefrontCountryCode, error in if let error = error { print("Error fetching storefront country code: \(error.localizedDescription)") completion(nil) return } guard let countryCode = storefrontCountryCode else { print("country code error") completion(nil) return } completion(countryCode) } }
Replies
0
Boosts
0
Views
962
Activity
May ’23
MPMediaLibrary.default().addItem broken in macOS 13.4 / Catalyst
The following line of code worked fine in macOS 13.3 / Catalyst: try await MPMediaLibrary.default().addItem(withProductID: "1678639572") Since the 13.4 update it now throws an error: The operation couldn’t be completed. (MPErrorDomain error 11.) Although the Apple Music track with catalog Id 1678639572 does seem to get added to the library regardless. MPError.errorCode 11 is an undocumented value. Can someone please advise what error code 11 actually means, and if there's a workaround? I've raised this as feedback id FB12196635.
Replies
0
Boosts
0
Views
1k
Activity
May ’23
Catalog relationships empty for /me/library/albums. How to reconcile ?
For some library records, the catalog relationships is empty in the response to request: /v1/me/library/albums?include=catalog The json will look like that: "catalog": { "href": "/v1/me/library/albums/l.mbhaBBs/catalog", "data": [] } The catalog relationship url (/v1/me/library/albums/l.mbhaBBs/catalog) will give: { "errors": [ { "id": "YS7BUVCTXA3QWDVX3YQQSCPEUY", "title": "No related resources", "detail": "No related resources found for catalog", "status": "404", "code": "40403" } ] } I am talking about an album that was added from the catalog in the first place. When it happens, removing the album from the library and adding it again using the Apple Music app, resolves the issue. Is there another way to force the library-album to reconcile with the catalog-album using the API itself ?
Replies
1
Boosts
0
Views
837
Activity
May ’23
403 Error using userToken generated by MusicKit
I'm developing a flutter app and using https://pub.dev/packages/music_kit to leverage MusicKit to handle the initial user permission request and generating the userToken. I then need to make requests to the Apple Music API from my server through a background task to retrieve the user's heavy rotation information which is used to recommend events. The initial authorization works as expected and generates a developer token and user token, but when I use the developer token and user token in a get request to https://api.music.apple.com/v1/me/storefront it returns a 403 error "Invalid authentication". I can't seem to figure out what's causing this as I'm using the user token generated from MusicKit, I also test the developer token and it works on non-user specific api end points, so it's a correct developer token. Are user tokens generated by the MusicKit swift code only able to be used in MusicKit calls in the app? Also when making a status request through MusicKit I get "MusicAuthorizationStatus.authorized(musicUserToken: null)" which seems strange as I would assume the token that's returned would be included in the status if it's including the parameter musicUserToken. The account being connected is on a 1 month free trial at the moment if that makes a difference.
Replies
0
Boosts
1
Views
780
Activity
May ’23