【问题标题】:Youtube application launch from other app is not working in ios 9从其他应用程序启动的 Youtube 应用程序在 ios 9 中不起作用
【发布时间】:2016-04-30 00:40:40
【问题描述】:
  if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"https://www.youtube.com/watch?v=VideoID"]]) {

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.youtube.com/watch?v=VideoID"]];
    }

输出: -canOpenURL:URL 失败:“youtube://www.youtube.com/watch?v=UFccvtrP1d8” - 错误:“此应用不允许查询方案 youtube”

【问题讨论】:

  • 为什么要检查canOpenURL?只需打开网址。
  • 我只需要在 youtube 应用程序中打开。您能帮忙吗?我想在其他部分做其他案例
  • 天气在 ios 9 上运行
  • stackoverflow.com/questions/30987986/… 你基本上必须将 youtube 计划列入白名单
  • 您是否在 plist 中添加了 LSApplicationQueriesSchemes

标签: ios objective-c youtube ios9


【解决方案1】:

试试这个

在 iOS 9 中,您必须将您的应用想要在 Info.plist 中的 LSApplicationQueriesSchemes 键(字符串数组)下查询的任何 URL 方案列入白名单:

将字符串添加为youtube

例如

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>youtube</string>
   </array>

二次检查 youtube 应用在您的设备中是否可用

例如

 NSString *Name = @"VideoID";

NSURL *linkToApp = [NSURL URLWithString:[NSString stringWithFormat:@"youtube://watch?v=%@",Name]]; // I dont know excatly this one 
NSURL *linkToWeb = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.youtube.com/watch?v=%@",Name]]; // this is correct


if ([[UIApplication sharedApplication] canOpenURL:linkToApp]) {
    // Can open the youtube app URL so launch the youTube app with this URL
    [[UIApplication sharedApplication] openURL:linkToApp];
}
else{
    // Can't open the youtube app URL so launch Safari instead
    [[UIApplication sharedApplication] openURL:linkToWeb];
}

了解更多关于游戏的信息Youtube Video

【讨论】:

    猜你喜欢
    • 2011-07-15
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-05
    • 2011-01-06
    相关资源
    最近更新 更多