如何通过点击 Swift 中的按钮打开 fb 和 instagram 应用程序

编程入门 行业动态 更新时间:2024-10-25 10:32:51
本文介绍了如何通过点击 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/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:

instagram/developer/mobile-sharing/iphone-hooks/

wiki.akosma/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: "instagram/")!) }

更多推荐

如何通过点击 Swift 中的按钮打开 fb 和 instagram 应用程序

本文发布于:2023-11-23 14:43:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   按钮   Swift   instagram   fb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!