Reputation:
Apple suggests us a way to search items in apple music with affiliate linking. But, is it possible to get information about the song from a link. For example this link: https://itun.es/ua/qzPyfb?i=1164089149. I need to get information from this link, that I can use to search for the song, for example, in MPMediaLibrary.
Upvotes: 1
Views: 168
Reputation:
So, I have found the answer. The last numbers are product id. Taking that link https://itun.es/ua/qzPyfb?i=1164089149. Imagine that we already get from string last numbers.
MPMediaLibrary *library = [MPMediaLibrary defaultMediaLibrary];
[library addItemWithProductID:trackId completionHandler:^(NSArray<__kindof MPMediaEntity *> * _Nonnull entities, NSError * _Nullable error) {
if (error) {
NSLog(@"%@", error);
} else {
if ([entities count]) {
for (MPMediaItem *item in entities) {
NSLog(@"%@", item.title);
}
} else {
NSLog(@"There is no track with this product Id. Bad link.");
}
}
}];
Upvotes: 1