Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23923] iOS 10: Ti.Media.queryMusicLibrary crashes the app

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-09-21T07:49:35.000+0000
Affected Version/sRelease 5.5.0
Fix Version/sRelease 6.0.0
ComponentsiOS
Labelsios10, musiclibrary, permissions, privacy, qe-6.0.0
Reporterjack sparrow
AssigneeHans Knöchel
Created2016-09-19T08:56:25.000+0000
Updated2016-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

Comments

  1. Hans Knöchel 2016-09-19

    Did you include the NSAppleMusicUsageDescription key 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.
  2. Hans Knöchel 2016-09-19

    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();
       
  3. jack sparrow 2016-09-19

    @hans , thank u i tried ur code gives error so i need to modify Ti files with ur commit
  4. Hans Knöchel 2016-09-19

    [~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!
  5. jack sparrow 2016-09-20

    @Hans Knoechel , thank u its worked when i patched my SDK with ur modifications thank u
  6. Hans Knöchel 2016-09-21

    PR (6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8407
  7. Chee Kiat Ng 2016-09-21

    PRs merged.
  8. Harry Bryant 2016-09-23

    Verified as fixed, when specifying NSAppleMusicUsageDescription in 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.*

JSON Source