如何通过单击中的按钮来打开Facebook和Instagram应用程序swift?某些应用程序重定向到Facebook应用程序并打开特定页面。我该怎么做?
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。其他示例在中ObjectiveC,我不知道= /
URL
ObjectiveC
看一下这些链接,它可以帮助您:
https://instagram.com/developer/mobile-sharing/iphone- hooks/
http://wiki.akosma.com/IPhone_URL_Schemes
否则,Instagram的一个简单示例可以在此处打开特定的个人资料(昵称:johndoe):
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/")!) }