[TIMOB-23923] iOS 10: Ti.Media.queryMusicLibrary crashes the app
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-09-21T07:49:35.000+0000 |
| Affected Version/s | Release 5.5.0 |
| Fix Version/s | Release 6.0.0 |
| Components | iOS |
| Labels | ios10, musiclibrary, permissions, privacy, qe-6.0.0 |
| Reporter | jack sparrow |
| Assignee | Hans Knöchel |
| Created | 2016-09-19T08:56:25.000+0000 |
| Updated | 2016-09-23T19:04:46.000+0000 |
Description
in new OS 10 apple added new permission for access music library , my issue with Ti.Media.queryMusicLibrary, when i call this method the app crashes , Ive tried to search for condition to check if user already gives access or request access to Music library can't find them !
var musicList = Ti.Media.queryMusicLibrary({
mediaType : Ti.Media.MUSIC_MEDIA_TYPE_MUSIC
});
after upgrade to ios 10 and appcelerator SDK to 5.5.0.GA , when u call the above method the app will crash !
any advices is very much appreciated
Did you include the
NSAppleMusicUsageDescriptionkey in your plist? It is required by iOS 10 and later. Although we added the usage-description-keys to the very most of our API's, we may need to add it to the music-library docs as well. We will update the docs and also provide new methods to check the music-library permissions.PR: https://github.com/appcelerator/titanium_mobile/pull/8397 Demo:
var win = Ti.UI.createWindow({ backgroundColor: "#fff" }); var btn = Ti.UI.createButton({ title: "Has permissions", top: 40 }); btn.addEventListener("click", function() { alert("Has permissions? " + Ti.Media.hasMusicLibraryPermissions()); }); var btn2 = Ti.UI.createButton({ title: "Request permissions & access library", top: 80 }); btn2.addEventListener("click", function() { if (!Ti.Media.hasMusicLibraryPermissions()) { Ti.API.info("Does not have permissions, yet. Will request now"); Ti.Media.requestMusicLibraryPermissions(function(e) { if (e.success) { Ti.API.info("Permissions granted, can access music library now."); // Ti.Media.queryMusicLibrary(); } else { Ti.API.error("Permissions denied!!"); } }) } else { Ti.API.info("Already has permissions, can access music library now."); // Ti.Media.queryMusicLibrary(); } }); win.add(btn); win.add(btn2); win.open();@hans , thank u i tried ur code gives error so i need to modify Ti files with ur commit
[~jackSparrow] It just crashes because it's not in the SDK, yet. That's why it is an open Pull Request in review :-) You can just add the plist-key for now and the app won't crash. The additional methods are just for an improved permission-handling. Of course you can patch your current SDK already. Thanks!
@Hans Knoechel , thank u its worked when i patched my SDK with ur modifications thank u
PR (6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8407
PRs merged.
Verified as fixed, when specifying
NSAppleMusicUsageDescriptionin the plist, app no longer crashes on iOS10. Tested On: iPhone 6 Plus 10.0.1 Device iPhone 5S 9.3.5 Device Mac OSX El Capitan 10.11.6 Ti SDK: 6.0.0.v20160922165510 Appc Studio: 4.8.0.201609191928 Appc NPM: 4.2.8-7 App CLI: 6.0.0-51 Xcode 8.0 Node v4.4.7 *Closing ticket.*