本文介绍了如何通过点击 Swift 中的按钮打开 fb 和 instagram 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过点击 swift 中的按钮打开 Facebook 和 Instagram 应用程序?某些应用程序重定向到 Facebook 应用程序并打开特定页面.我怎样才能做同样的事情?

How can I open Facebook and Instagram app by tapping on a button in swift? Some apps redirect to the Facebook app and open a specific page. How can I do the same thing?

我找到了:

var url = NSURL(string: "itms://itunes.apple.com/de/app/x-gift/id839686104?mt=8&uo=4")

if UIApplication.sharedApplication().canOpenURL(url!) {
  UIApplication.sharedApplication().openURL(url!)
}

但我必须知道应用URL.其他示例在 ObjectiveC 中,我不知道 =/

but I have to know the app URL. Other examples were in ObjectiveC, which I don't know =/

推荐答案

看看这些链接,它可以帮助你:

Take a look at these links, it can help you:

https://instagram.com/developer/mobile-sharing/iphone-hooks/

http://wiki.akosma.com/IPhone_URL_Schemes

通过本机 Facebook 应用打开 Facebook 链接iOS

否则,这里有一个 Instagram 的快速示例,用于打开特定的个人资料(昵称:johndoe):

Otherwise, there is a quick example with Instagram for opening a specific profile (nickname: johndoe) here:

var instagramHooks = "instagram://user?username=johndoe"
var instagramUrl = NSURL(string: instagramHooks)
if UIApplication.sharedApplication().canOpenURL(instagramUrl!) {
  UIApplication.sharedApplication().openURL(instagramUrl!)
} else {
  //redirect to safari because the user doesn't have Instagram
  UIApplication.sharedApplication().openURL(NSURL(string: "http://instagram.com/")!)
}

这篇关于如何通过点击 Swift 中的按钮打开 fb 和 instagram 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 21:30