带有社交元数据的 Firebase 动态链接未在 iMessage 上显示图像(iOS 条消息)
Firebase Dynamic Links with Social Metadata not showing image on iMessage (iOS Messages)
我在动态链接和社交元数据方面遇到问题。在 Facebook 上共享时似乎工作正常...图像已正确附加。但是,当我在 iOS 上使用“消息”进行分享时...没有图像出现。只是 Firebase 文件夹徽标。
我遇到了完全相同的问题,我找到了一种通过创建 LPLinkMetadata of LinkPresentation 在 iMessage 中显示预览图像的方法。尽管它没有解决核心问题,但它似乎在起作用。
基本上,我先下载要在预览中显示的图像,然后根据该图像创建 LPLinkMetadata。
let image = UIImage(data: data)! //Image to show in preview
let metadata = LPLinkMetadata()
metadata.imageProvider = NSItemProvider(object: image)
metadata.originalURL = url //dynamic links
metadata.title = "Holland Bloorview Kids Rehabilitation Hospital on Flixxaid"
let metadataItemSource = LinkPresentationItemSource(metaData: metadata)
let activity = UIActivityViewController(activityItems: [metadataItemSource], applicationActivities: [])
self.present(activity, animated: true)
而 LinkPresentaionItemSource 来自 this blog。
class LinkPresentationItemSource: NSObject, UIActivityItemSource {
var linkMetaData = LPLinkMetadata()
//Prepare data to share
func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata? {
return linkMetaData
}
//Placeholder for real data, we don't care in this example so just return a simple string
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
return "Placeholder"
}
/// Return the data will be shared
/// - Parameters:
/// - activityType: Ex: mail, message, airdrop, etc..
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
return linkMetaData.originalURL
}
init(metaData: LPLinkMetadata) {
self.linkMetaData = metaData
}
}
我在动态链接和社交元数据方面遇到问题。在 Facebook 上共享时似乎工作正常...图像已正确附加。但是,当我在 iOS 上使用“消息”进行分享时...没有图像出现。只是 Firebase 文件夹徽标。
我遇到了完全相同的问题,我找到了一种通过创建 LPLinkMetadata of LinkPresentation 在 iMessage 中显示预览图像的方法。尽管它没有解决核心问题,但它似乎在起作用。
基本上,我先下载要在预览中显示的图像,然后根据该图像创建 LPLinkMetadata。
let image = UIImage(data: data)! //Image to show in preview
let metadata = LPLinkMetadata()
metadata.imageProvider = NSItemProvider(object: image)
metadata.originalURL = url //dynamic links
metadata.title = "Holland Bloorview Kids Rehabilitation Hospital on Flixxaid"
let metadataItemSource = LinkPresentationItemSource(metaData: metadata)
let activity = UIActivityViewController(activityItems: [metadataItemSource], applicationActivities: [])
self.present(activity, animated: true)
而 LinkPresentaionItemSource 来自 this blog。
class LinkPresentationItemSource: NSObject, UIActivityItemSource {
var linkMetaData = LPLinkMetadata()
//Prepare data to share
func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata? {
return linkMetaData
}
//Placeholder for real data, we don't care in this example so just return a simple string
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
return "Placeholder"
}
/// Return the data will be shared
/// - Parameters:
/// - activityType: Ex: mail, message, airdrop, etc..
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
return linkMetaData.originalURL
}
init(metaData: LPLinkMetadata) {
self.linkMetaData = metaData
}
}