Apple 在 StoreKit 框架中提供了一种方法来检测用户是否订阅了苹果音乐,尽管它根本不起作用。我订阅了 Apple Music,既可以在我的应用程序中收听歌曲,也可以从我的应用程序中将项目添加到我的资料库中——但是,当我请求我的功能时,它并没有说我也有。这是我的代码:
let serviceController = SKCloudServiceController()
serviceController.requestCapabilities { (capability:SKCloudServiceCapability, err:Error?) in
print("error in capability check is \(err)")
switch capability {
case SKCloudServiceCapability.musicCatalogPlayback:
print("user has Apple Music subscription and can play music from apple music api")
case SKCloudServiceCapability.addToCloudMusicLibrary:
print("user has an Apple Music subscription, can play music from api, also can add to their music library")
case SKCloudServiceCapability.musicCatalogSubscriptionEligible:
print("user does not have subscription")
default:
print("default and capability is \(capability.rawValue)")
}
}
每次我运行我的应用程序时,它都会打印“默认值和能力为 257”。我已经尝试卸载/重新安装可能十几次了——每次都一样。
请注意,我确实可以通过 Apple Music api 获取我的用户令牌并将歌曲添加到我的库中。
其他任何人都经历过这种情况,是否有另一种解决方法来查看用户是否订阅了 Apple Music?