ios - 检查是否安装了推特应用程序

标签 ios swift twitter

我正在开发一个应用程序,我需要在 Twitter 中写一条消息(当用户点击 Twitter 图标时)。

如何检测是否安装了 Twitter 应用程序?

最佳答案

只需使用 canOpenURL(_:) 检查即可。

swift 3.0

if (UIApplication.shared.canOpenURL(URL(string:"twitter://"))) {
    print("Twitter is installed")
}

Swift 2.3 或更低版本

if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"twitter://"))) {
    print("Twitter is installed")
}

关于ios - 检查是否安装了推特应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40589968/

相关文章:

ios - iOS 中的 ImageView

ios - 如何将相机动画转换为折线(谷歌地图)

c# - Python 与 C# Twitter API 库

android - WebSockets 能耗

ios - 是否有可能知道用户何时在 iOS 7 中购买了我的其他应用程序?

swift - 可靠地检测计算机是否要休眠

php - 从帐户 URL 生成 data-widget-id (Twitter)

twitter - 我有很多推文的 ID;如何在不超过速率限制的情况下使用 Twitter API 获取他们的完整信息?

iphone - iOS,使用下划线与直接使用 iVar

swift - 未找到当前用户