如何通过点击 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 应用程序
发布评论