从网络运行iOS应用程序(角度)



我正在开发一个iOS应用程序 我有一个由 Angular 设计的付款页面

用户单击iOS应用程序中的付款按钮,我运行一个带有很少参数的URL页面:

UIApplication.sharedApplication().openURL(NSURL(string:"http://www.testt.com/price/personId/packageName")!)

价格是钱 用户在文本字段中输入了 和包名称 ID 架构名称 我应该将其发送到运行我的应用程序的网页(运行该字符串返回应用程序( 我已经在 info.plist 中声明

然后在付款成功或不成功后。 它应该通过单击网站上的"返回应用程序"按钮返回到应用程序。

实际上 angular 运行我用 url 发送的包名称,如下所示:http://packageName://

我尝试通过这样的通用链接来实现这一点:packageName://但由于 url 中的特殊字符而无法打开此链接.I 使用编码方法对字符进行编码但不成功,因为 URL 删除了字符://然后我尝试了我面临的应用程序站点关联方法无法解析应用程序站点关联文件

所以我有几个问题要问你:

1_is有什么技巧可以使用特殊字符运行 url 吗? 如果你是我,你会2_what怎么做??

3_i也尝试了苹果应用程序网站关联,但无法解析错误,我对此方法有疑问,此文件如何打开我的应用程序? 这种方式: applink:http://msite.com ?? 因为它再次包含空格字符

请原谅我最后糟糕的英语

在投票否决之前与我交谈

更新:

var encodedChars="openMyApp"    //schema name
encodedChars=encodedChars.addingPercentEncoding(withAllowedCharacters:CharacterSet.alphanumerics)!

let url="http://test.com/#/payment/(id)/(price!)/(encodedChars)"

UIApplication.shared.openURL(NSURL(string: url)! as URL)

角度代码 :

if (this.accounting.packageName === 'openMyApp') {
this.url = this.accounting.packageName + '://';
} else {
this.url = 'http://' + this.accounting.packageName;
}
<a class="btn btn-default" title="" href="{{url}}"></a>

我已经为我的应用程序实现了自定义 url 方案。如果我写这样的东西

myappName://

在 Safari 浏览器中,按 Enter 键,我的应用将打开。

我的 angular + 后端开发人员正在使用这行代码使用自定义 url 方案打开我的应用程序。 他正在按照我可以读取的方案发送参数

this.document.location.href = 'myappname://appname.com/login?name='+id+'&id='+token;

按照这两个简单的步骤,希望对您有所帮助。


1.如何实现自定义网址方案

官方文档

有用的链接


2.如何在应用程序委托中使用参数处理自定义 URL 方案

在此函数中处理自定义 URL 并读取appDelegate

参数
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if let query = url.query {
//that's my logic. yours url may be different
let components = query.components(separatedBy: "=")
print(components)
}

}

如果您需要任何帮助,请告诉我

相关内容

最新更新