2015-09-26 167 views
-1

當用戶按下特定的UIButton時,應用程序應該在Spotify應用程序中打開一首歌曲,如果該應用程序不存在於手機上,我需要它將用戶轉到AppStoreSpotify應用程序,以便用戶可以下載它。點擊按鈕進入`AppStore`

艾想法我怎麼能這樣做?

謝謝。

回答

1

要做到這一點,你必須:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:spotifyUrl]]) 
{ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:spotifyUrl]]; 
} 
else 
{ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:linkOfSpotifyOnAppstore]] 
} 
+0

我知道這是這樣的,但我怎麼知道什麼是Spotify的在AppStore上的聯繫? – user3783005

+1

谷歌搜索:https://itunes.apple.com/us/app/spotify-music/id324684580?mt=8 –

+0

而不是使用'openURL'到iTunes中的鏈接,你應該使用'SKStoreProductViewController'。 – rmaddy