당신은 애플의 뮤직 앱에 침을 열기 위해 딥 링크를 사용한다
: 당신이 당신의 능력을 (확인 SKCloudServiceController의 API를 통해 승인을 요청하는 데 필요한 모든의 https://affiliate.itunes.apple.com/resources/documentation/linking-to-the-itunes-music-store/
먼저 예를 들어, 당신의 장치의 재생을 허용하는 경우 Apple 음악 트랙).
[SKCloudServiceController requestAuthorization:^(SKCloudServiceAuthorizationStatus status) {
self.cloudServiceController = [[SKCloudServiceController alloc] init];
[self.cloudServiceController requestCapabilitiesWithCompletionHandler:^(SKCloudServiceCapability capabilities, NSError * _Nullable error) {
[self.cloudServiceController requestStorefrontIdentifierWithCompletionHandler:^(NSString * _Nullable storefrontIdentifier,
NSError * _Nullable error) {
NSString *identifier = [[storefrontIdentifier componentsSeparatedByString:@","] firstObject];
identifier = [[identifier componentsSeparatedByString:@"-"] firstObject];
NSString *countryCode = [self countryCodeWithIdentifier:identifier];
}];
}];
}];
다음으로 국가 코드를 정의하는 데 사용할 상점 앞 식별자를 요청할 수 있습니다. 모든 식별자와 해당 국가 코드가 포함 된 .plist 파일을 프로젝트에 포함하는 것이 좋습니다. (여기에서 .plist 파일을 찾을 수 있습니다 https://github.com/bendodson/storefront-assistant/blob/master/StorefrontCountries.plist). Apple Music API 요청에 대한 국가 코드가 필요합니다.
- (NSString *)countryCodeWithIdentifier:(NSString *)identifier {
NSURL *plistURL = [[NSBundle mainBundle] URLForResource:@"CountryCodes" withExtension:@"plist"];
NSDictionary *countryCodeDictionary = [NSDictionary dictionaryWithContentsOfURL:plistURL];
return countryCodeDictionary[identifier];
}
일단 각 국가 코드가 있으면 Apple Music의 API에서 트랙을 검색 할 수 있습니다. GET https : //itunes.apple로 요청하십시오.다음 매개 변수를 사용하여 COM/검색 :이 요청의 응답으로
NSDictionary *parameters = @{
@"isStreamable" : @(YES),
@"term" : @"your search parameter"
@"media" : @"music",
@"limit" : @(5),
@"country" : @"your country code"
};
, 당신은 관련된 매개 변수를 많이, 트랙 결과의 배열을 받게됩니다. 그 중 하나가 "trackViewUrl"입니다. Apple 음악 앱에 깊은 링크를 만들기 위해이 trackViewUrl에 다음 매개 변수를 추가하기 만하면됩니다.
NSString *appleMusicDeepLinking = [NSString stringWithFormat:@"%@&mt=1&app=music", response[0][@"trackViewUrl"]];
Apple 뮤직에서 사용자가 노래를 열도록 허용해야한다고 말하는 어떤 정책이 있습니까? –