在新的 OS 10
Apple 中,我添加了访问音乐库
的新权限,我的问题是 Ti.Media.queryMusicLibrary
,当我调用此方法时,应用程序崩溃,我尝试搜索条件来检查用户是否已授予访问权限或请求访问音乐库找不到它们!
var musicList = Ti.Media.queryMusicLibrary({
mediaType : Ti.Media.MUSIC_MEDIA_TYPE_MUSIC
});
升级到ios
10和appcelerator
SDK到5.5.0.GA后,当您调用上述方法时,应用程序会崩溃!
最佳答案
尝试将以下键添加到您的 tiapp.xml ios 标签:
NSAppleMusicUsageDescription
<ios>
<plist>
<dict>
<key>NSAppleMusicUsageDescription</key>
<string>Allow this app to access your music library.</string>
<key>UISupportedInterfaceOrientations~iphone</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIRequiresPersistentWiFi</key>
<false/>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</plist>
</ios>
此外,
将该 Ti 代码包装在 try-catch block 中以便更安全地使用。
根据当前文档,有一种方法可以检查 Audio Permissions , 虽然我不确定它是否会请求音乐库许可,并且它只能在 Ti SDK 6.0.0 上运行,目前还没有对公众开放。
有关更多信息,请参阅这些链接:
关于ios - Ti.Media.queryMusicLibrary 在新更新后崩溃应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39568417/