Kir*_*aev 2 twitter sharing deep-linking ios swift
我正在尝试在不使用 Twitter Kit 库的情况下将 iOS 应用程序中的图像和标题共享到 Twitter。理想情况下,它应该像我在这篇文章中附加的 Spotify 共享一样工作。对此有什么想法吗?
我浏览了 Twitter 文档,但没有看到太多关于这个主题的内容。
我也尝试过使用 Apple 的 SLComposeViewController,但问题是当图像出现在 Twitter 上时,图像显示为 URL 而不是图像:
if let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter) {
vc.setInitialText("some caption")
vc.add(UIImage(named: "my_image",
in: InternalConstants.bundle,
compatibleWith: nil)!)
vc.modalPresentationStyle = .formSheet
nc.present(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
请不要将此问题标记为重复,除非该解决方案提供即时深层链接(如所附 gif 所示)。
谢谢你!
Spotify 不共享图像和标题!相反,它共享一个指向该网站的链接,该网站包含适当的元数据来显示image、等。您可以通过阅读有关开放图谱协议和丰富链接的title更多description信息来实现此类链接
总之,目标页面应在标题中包含以下内容:
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="https://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="https://ia.media-imdb.com/images/rock.jpg" />
Run Code Online (Sandbox Code Playgroud)
示例取自 ogp.me

请注意,请记住一些社交媒体和平台支持不同的元!确保在所有目标平台(WhatsApp、Telegram、Facebook、Tweeter 等)中测试您的链接

| 归档时间: |
|
| 查看次数: |
1735 次 |
| 最近记录: |