![](/img/trans.png)
[英]Redirecting from BankID app with custom URL scheme in iOS (Flutter) not working
[英]URL Scheme not working from native iOS app
我有一个自定义的URL方案和一个TARGET应用程序,该应用程序注册了该方案才能识别。
当我在移动Safari中启动WEB应用程序并按WEB应用程序中的按钮时,该按钮提供了URL链接,并且启动了专用的TARGET应用程序-这是您所期望的行为。
但是,如果启动本机SOURCE应用程序并在UIButton上执行操作,然后在其中调用appdelegate到openURL并传递与Web应用程序相同的URL,则不会启动TARGET应用程序。 [UIApplication canOpenURL]检查甚至返回NO,这很奇怪,因为TARGET App DID已正确注册了该自定义URL方案,否则将无法从Web应用程序运行。
有什么帮助吗?
PS:SOURCE和TARGET只是SO的方便名称。
更新:
- (IBAction)handleAction:(id)sender
{
NSString *urlString = @"nda://nda.undernda/actionundernda?someparamters..";
BOOL isURLSchemeRegistered = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:urlString]];
if (isURLSchemeRegistered == YES)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}
else
{
//go to appstore
}
}
好的,所以问题在于他的网址包含使用UTF8编码无法转义的字符。
解:
NSString *urlString = @"sorry..can't show this :(";
NSString *escapedUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url =[ NSURL URLWithString:escapedUrlString];
[[UIApplication sharedApplication] openURL:url];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.