我有一个推送通知到达我的iOS应用程序,有轨道id。我能够成功打开声音云应用程序到正确的轨道,但我想在移动safari中打开该轨道,如果设备没有安装声音云应用程序。下面是我使用的代码:
NSString *soundCloudApp = @"soundcloud:tracks:";
NSString *soundCloudUrl = @"https://api.soundcloud.com/tracks";
NSURL *fanPageURL = [NSURL URLWithString:[soundCloudApp stringByAppendingString:data]];
if (![[UIApplication sharedApplication] openURL: fanPageURL]) {
//fanPageURL failed to open. Open the website in Safari instead
NSURL *webURL = [NSURL URLWithString:[soundCloudUrl stringByAppendingString:data]];
[[UIApplication sharedApplication] openURL: webURL];
}
问题是,如果我插入https://api.soundcloud.com/tracks/my_track_id声音云返回未经授权的访问。如果我尝试https://soundcloud.com/tracks/my_track_id,我得到一个没有找到的页面。任何方式我可以打开轨道在safari只给出轨道id?
谢谢!
您应该使用轨迹表示的permalink_url
属性
也许你应该在if语句中使用
if (![[UIApplication sharedApplication] canOpenURL: fanPageURL])
{
//open safari
}