如何通过点击Swift中的按钮打开fb和instagram应用程序 [英] How to open fb and instagram app by tapping on button in Swift

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

问题描述

如何通过点击Swift中的按钮打开Facebook和instagram应用程序?在某些应用程序中,通过点击重定向到Facebook应用程序的东西并打开一些页面。如何在Swift中做同样的事情?

How can I open facebook and instagram app by tapping on button in Swift? In some apps by tapping on something it redirects to the facebook app and opens some page. How can I do the same thing in Swift?

我发现了,

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。其他例子在ObjC中,我根本不知道= /

but here I must to know an app URL. And other examples was in ObjC, which I do not know at all =/

推荐答案

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

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

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

http://wiki.akosma.com/IPhone_URL_Schemes

在iOS上打开Facebook应用程序的Facebook链接

否则有一个Instagram的例子,用于打开特定的个人资料(昵称:johndoe here):

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应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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