【发布时间】:2018-10-16 21:59:55
【问题描述】:
为了打开带有某些帖子的 Instagram 应用,我使用以下代码:
func instaOpen(_ postId: String, _ postUrl: String){
let appURL = URL(string: "instagram://media?id=\(postId)")!
if UIApplication.shared.canOpenURL(appURL) {
UIApplication.shared.open(appURL, options: [:], completionHandler: nil)
} else {
// if Instagram app is not installed, open URL inside Safari
let webURL = URL(string: postUrl)!
let svc = SFSafariViewController(url: webURL)
present(svc, animated: true, completion: nil)
}
}
调用 instaOpen 函数时——instagram 应用打开,但登录提示强制弹出。无论您做什么 - 关闭它或继续登录,查询的帖子根本不会打开(参见 gif)。 这种情况最近开始发生,在我更新了我的应用并将部署目标推送到 iOS12 之后。
我的LSApplicationQueriesSchemes 中确实列出了 instagram,并且我 100% 肯定正确的mediaID 正在传递给instaOpen func(代码之前有效)。
如果有任何关于如何解决此问题并在 Instagram 应用中实际打开 Instagram 帖子的建议,请告诉我。
【问题讨论】:
标签: ios swift instagram instagram-api