2

My app imports music from the Music app via MPMediaPickerController. A modal will appear even if the user has deleted the music app. However, if it was deleted in iOS13, the modal no longer appears. So I want to check if the Music app is installed. I tried the following code and confirmed that YES is returned even if it is not installed.

- (BOOL)isInstalledMusicApp
{
    NSURL *url = [NSURL URLWithString:@"music://"];
    return [[UIApplication sharedApplication] canOpenURL: url];
}
Nullable
  • 761
  • 5
  • 17
  • Possible duplicate of [How to check app is installed or not in phone](https://stackoverflow.com/questions/41545283/how-to-check-app-is-installed-or-not-in-phone) – inexcitus Oct 25 '19 at 05:57
  • @inexcitus Thanks for your comment. I think this code is the same as the linked one. Even if it is not installed, YES is returned. – Naoki Odajima Oct 25 '19 at 06:22
  • You are right, no matter whether you install `Music app ` , `canOpenURL` always returns `YES`. But I found in the test that when I use `canOpenURL`, will prompt `Restore "Music"`. If you don't have Pop up, you can consider whether it is in the main thread – Nullable Oct 25 '19 at 06:39
  • If you still want to know if it is installed, you can use `[UIApplication sharedApplication] openURL` directly, `completionHandler` will return the result. – Nullable Oct 25 '19 at 06:45
  • @Nullable Thank you for the advice. I'll do my best with this hint! – Naoki Odajima Oct 25 '19 at 06:46

0 Answers0