【发布时间】:2015-02-26 07:21:58
【问题描述】:
我想在应用程序进入后台后启动它。我使用了以下代码:
NSString *customURL = @"TestApp://?caller=TestApp%3A%2F%2Fblabla";
if ([[UIApplication sharedApplication]
canOpenURL:[NSURL URLWithString:customURL]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL error"
message:[NSString stringWithFormat:
@"No custom URL defined for %@", customURL]
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
}
但它在模拟器中运行良好,但在 iOS 设备中无法运行:我已经在 iPhone 5 和 iOS 8.1.3 中进行了测试
如果我们需要做任何额外的事情,请指导我。 这里的 TestApp 是我放在 info.plist 文件中的 URL 方案。
【问题讨论】:
-
您必须在
-info.plist文件中指定它正在侦听的 URL。完成了吗? -
stackoverflow.com/questions/23385542/… 检查此链接它会帮助你..:)
-
如果 Apple 阻止您在没有用户交互的情况下将应用程序置于前台,我不能说我会感到惊讶。有趣的想法...
-
是的,我已经在 info.plist 中设置了所有内容。在设备中,我得到以下警告。
-
2 月 26 日 13:15:32 iPhone SpringBoard[43] :[FBSystemService] 启动 com.abc.xyz 的 URL 时出错:安全性 (3) 2 月 26 日 13:15:32 iPhone lsd [74] :LaunchServices:应用程序启动失败 - 收到错误安全
标签: ios objective-c url-scheme