0 Replies
      Latest reply on Nov 8, 2019 2:24 PM by adfasdfasdfsdf
      adfasdfasdfsdf Level 1 Level 1 (0 points)

        I am making a music app with swift. The app lets users play music through their Apple Music subscription via their Apple Music app. I am able to check whether the user has an Apple Music subscription via:

         

        SKCloudServiceController().requestCapabilities { (capability:SKCloudServiceCapability, err:Error?) in
        
            guard err == nil else {
                print("error in capability check is \(err!)")
                return
            }
        
            if capability.contains(SKCloudServiceCapability.musicCatalogPlayback) {
                print("user has Apple Music subscription")
            }
        
            if capability.contains(SKCloudServiceCapability.musicCatalogSubscriptionEligible) {
                print("user does not have subscription")
            }
        
        }

         

        However: there are scenarios where somebody will, for some reason, have an Apple Music subscription but not have the Apple Music app downloaded on their device. If the user has the subscription but not the device, I want to essentially treat that case as if they do not have a subscription at all, i.e. we cannot play music via Apple Music.

         

        So, I go searching for ways to add a check for if Apple Music is on the user's device. I find this answer combined with this resource for finding Apple Music's url scheme and conclude I can check if a user has both an Apple Music subscription and the Apple Music app installed on their device via:

         

        SKCloudServiceController()requestCapabilities { (capability:SKCloudServiceCapability, err:Error?) in
        
            guard err == nil else {
                print("error in capability check is \(err!)")
                return
            }
        
            if capability.contains(SKCloudServiceCapability.musicCatalogPlayback) && UIApplication.shared.canOpenURL(URL(string: "music://")!) {
                print("user has Apple Music subscription and has the apple music app installed")
            }
        
            if capability.contains(SKCloudServiceCapability.musicCatalogSubscriptionEligible) || !UIApplication.shared.canOpenURL(URL(string: "music://")!) {
                print("user does not have subscription or doesn't have apple music installed")
            }
        
        }

         

        The issue is, even after deleting Apple Music from my device, the first case, i.e. the one that prints "user has Apple Music subscription and has the apple music app installed" is still being called. I believe I have the correct url scheme because when changing "music://" to "musi://", the second case, i.e. the one that prints "user does not have subscription or doesn't have apple music installed" is being called.

         

        When trying to open URL(string: "music://") with Apple Music deleted via UIApplication.shared.open(URL(string: "music://")!), I am hit with the following alert.

         

        So why is the device saying that I can open URL(string: "music://") even after Apple Music is deleted? Is the URL capable of being opened, but the result is simply the presentation of the above alert? Is this the correct way to confirm that the user has Apple Music installed on their device? Is there even a way to confirm the user has Apple Music installed on their device?