Dan*_*gal 6 iphone safari objective-c whatsapp
我正在尝试使用Whatsapp'sWeb API 将文本发送到任何有效号码(即使是不在我的联系人列表中的号码)。如果用户Whatsapp安装了该应用程序,它将打开。否则,浏览器将打开。
在 Xcode 中,模拟 iPhone,问题是当 Safari 打开 URL 时,我收到一条弹出消息Safari cannot open the page because the address is invalid。但是地址实际上是正确的,并且在弹出窗口后面加载了正确的页面。我不明白问题是什么。我该怎么做才能没有这个弹出窗口?
这是我在视图控制器中使用的代码段:
NSString * plainString = @"https://api.whatsapp.com/send?phone=5511123456789&text=Hello";
NSString * encodedString = [plainString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL * whatsappURL = [NSURL URLWithString:encodedString];
if([[UIApplication sharedApplication] canOpenURL:whatsappURL]) {
[[UIApplication sharedApplication] openURL:whatsappURL];
}
Run Code Online (Sandbox Code Playgroud)
我还添加whatsapp到了LSApplicationQueriesStringsin Info.plist。
Objective-C上周开始学习,我真的不知道如何使用其他类似的答案来解决这个问题。| 归档时间: |
|
| 查看次数: |
1485 次 |
| 最近记录: |