iOS9:canOpenURL为WhatApp的url方案返回false [英] iOS9: canOpenURL returning false for WhatApp's url scheme

查看:524
本文介绍了iOS9:canOpenURL为WhatApp的url方案返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我目前的项目中,我需要在iOS应用中分享whatsapp上的文字。

In my current project I need to share text on whatsapp from iOS app.

这是我在whatsapp上分享文字的代码: -

Here is my code to share text on whatsapp:-

NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}

canOpenURL 在iOS9中始终返回false。

but canOpenURL always returning false in iOS9.

有iOS9隐私政策吗?
任何人都可以帮助我。

Is there any iOS9 privacy policy ? Can anyone help me out.

提前致谢。

推荐答案

在iOS 9中,您必须将您的应用程序想要在LSApplicationQueriesSchemes键(字符串数组)下的Info.plist中查询的任何URL方案列入白名单:

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):

例如:

所以在你的情况下,而不是 fb twitter 您必须指定 whatsapp

So in your case, instead of fb and twitter you will have to specify whatsapp.

请注意,此机制仅适用于canOpenURL而不适用于openURL。您不需要在Info.plist中列出一个方案就可以使用openURL打开它。
希望有所帮助。

Note that this mechanism only applies to canOpenURL and not openURL. You do not need to have a scheme listed in Info.plist to be able to open it with openURL. Hope that helps.

这篇关于iOS9:canOpenURL为WhatApp的url方案返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆