gpt4 book ai didi

ios - 从其他应用程序启动的 Youtube 应用程序在 iOS 9 中不起作用

转载 作者:行者123 更新时间:2023-11-28 18:09:13 26 4
gpt4 key购买 nike

  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”- 错误:“不允许此应用查询 scheme youtube”

最佳答案

试试这个

In iOS 9 you must whitelist any URL schemes your App wants to query in Info.plist under the LSApplicationQueriesSchemes key (an array of strings):

将字符串添加为 youtube

例如

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

secondary check that the youtube app is available or not in your device

例如

 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

关于ios - 从其他应用程序启动的 Youtube 应用程序在 iOS 9 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34963222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com