Link Presentation

RSS for tag

Fetch, provide, and present rich links in your app using Link Presentation.

Posts under Link Presentation tag

12 Posts

Post

Replies

Boosts

Views

Activity

Bug: Business name displayed incorrectly only in Location Share Preview (Apple Maps Metadata issue)
Hi everyone, I’m facing a very specific issue with our business location on Apple Maps. In the Apple Business Connect dashboard, our name is correctly set as "ANLOG Lojistik". It also appears correctly within the Apple Maps app itself. However, when we share the location via WhatsApp or iMessage, the "Preview Card" (Metadata) displays the name as "Anlog LojİStİK". It seems like a character rendering bug (specifically with Turkish character case sensitivity). Even standard characters like 'S' and 'K' are being forced into uppercase randomly. When you click the link, it opens correctly in Apple Maps, but the preview remains broken. Apple Support says "it's a 3rd party app issue," but this happens because the LPMetadataProvider fetches this specific data from Apple servers. Has anyone experienced a metadata sync/cache issue like this before? How can we force Apple to refresh the "Place Card" preview data?
0
0
156
May ’26
Why my link color changes back to system default on click and hold?
I currently have a custom UITextView that properly changes the color of a link to the custom color I have set, however, when I click and hold the link, and the animation plays that makes the link bigger and creates a boarder around the link before previewing the website, the link changes briefly back to the system default color, and when letting go, it changes back to my custom color. Is there anyway to have the link always be my custom color, even when clicking and holding? struct AutoDetectedClickableDataView: UIViewRepresentable { let text: String let dataDetectors: UIDataDetectorTypes @Binding var height: CGFloat private func dataDectectorValue(_ dataDectecor: UIDataDetectorTypes) -> UInt64 { var checkingTypes: [NSTextCheckingResult.CheckingType] = [] if dataDetectors.contains(.phoneNumber) { checkingTypes.append(.phoneNumber) } if dataDetectors.contains(.link) { checkingTypes.append(.link) } if dataDetectors.contains(.address) { checkingTypes.append(.address) } if dataDetectors.contains(.calendarEvent) { checkingTypes.append(.date) } if checkingTypes.isEmpty { return 0 } let intCheckingTypes: UInt64 = checkingTypes.reduce(0) { result, checkingType in UInt64(result) | UInt64(checkingType.rawValue) } return intCheckingTypes } func makeUIView(context: Context) -> UITextView { let textView = UITextView() textView.dataDetectorTypes = dataDetectors textView.isEditable = false textView.isScrollEnabled = false textView.backgroundColor = .clear textView.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0), compatibleWith: textView.traitCollection) textView.textColor = UIColor.label textView.adjustsFontForContentSizeCategory = true textView.textContainer.lineBreakMode = .byWordWrapping textView.textContainerInset = .zero textView.textContainer.lineFragmentPadding = 0 textView.translatesAutoresizingMaskIntoConstraints = false textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) textView.setContentHuggingPriority(.defaultHigh, for: .horizontal) textView.linkTextAttributes = [.foregroundColor: JeromesColors.UILinkColor] textView.tintColor = JeromesColors.UILinkColor for gesture in textView.gestureRecognizers ?? [] { if gesture is UITapGestureRecognizer { gesture.view?.tintColor = JeromesColors.UILinkColor } } return textView } func updateUIView(_ uiView: UITextView, context: Context) { let font = UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0), compatibleWith: uiView.traitCollection) let color = UIColor.label let attributed = NSMutableAttributedString(string: text, attributes: [ .font: font, .foregroundColor: color ]) let detectorValue = dataDectectorValue(dataDetectors) var matchCount = 0 if !dataDetectors.isEmpty, detectorValue != 0 { let detector = try? NSDataDetector(types: detectorValue) detector?.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count)) { match, _, _ in guard let match = match else { return } if match.resultType == .date, let date = match.date, date < Date() { return } else { attributed.addAttributes([ .foregroundColor: JeromesColors.UILinkColor, .underlineStyle: NSUnderlineStyle.single.rawValue, ], range: match.range) matchCount += 1 } } } uiView.attributedText = attributed if matchCount == 0 { uiView.isSelectable = false } else if matchCount > 0 { uiView.isSelectable = true } DispatchQueue.main.async { uiView.layoutIfNeeded() let fittingSize = CGSize(width: uiView.bounds.width, height: .greatestFiniteMagnitude) let size = uiView.sizeThatFits(fittingSize) height = size.height } } }
0
0
199
Aug ’25
NSItemProvider iconProvider has a dynamic type rather than an image type
I'm using a LPMetadataProvider to get metadata for URLs. If I do this if itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier) { let item = try? await itemProvider.loadItem(forTypeIdentifier: UTType.image.identifier) // continue with code to convert data to UIImage... } That seems to fail quite often, even on larger sites like Amazon where users will expect to see an icon. I've noticed it's because sometimes the type is dyn.agq80w5pbq7ww88brrfv085u I'm assuming this is because something about the website response or the image data does not let the system determine if it is actually an image. If I just do this let type: String = "dyn.agq80w5pbq7ww88brrfv085u" if itemProvider.hasItemConformingToTypeIdentifier(type) { let item = try? await itemProvider.loadItem(forTypeIdentifier: type) // continue with code to convert data to UIImage... } Then I get the icon, so it is there and it is an image. The problem is, does this dynamic type cover everything? Should I even be doing that? Does anyone know precisely what causes this and are there recommendations on better ways to handle it? I know LPLinkView appears to do something to load these 'non-image' icons so I am assuming there are way. My assumption is that it would be safe to look at the results of itemProvider.registeredTypeIdentifiers() and if it has something use that as the type rather than coming up with a hardcoded list of types to check for.
2
0
1.1k
Jun ’24
How to get link preview (LPLinkMetadata) for Twitter post content like iMessage
In iMessage when you link a twitter post you have the following preview As you can see the content of the tweet is present. I wanted to replicate that so I used LPLinkMetadata and even found the "hidden" metadata.value(forKey: "_summary") to get the description. Below is the full code import SwiftUI import LinkPresentation class LinkViewModel : ObservableObject { let metadataProvider = LPMetadataProvider() @Published var metadata: LPLinkMetadata? @Published var image: UIImage? init(link : String) { guard let url = URL(string: link) else { return } metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in guard error == nil else { assertionFailure("Error") return } DispatchQueue.main.async { self.metadata = metadata } guard let imageProvider = metadata?.imageProvider else { return } imageProvider.loadObject(ofClass: UIImage.self) { (image, error) in guard error == nil else { // handle error return } if let image = image as? UIImage { // do something with image DispatchQueue.main.async { self.image = image } } else { print("no image available") } } } } } struct MetadataView : View { @StateObject var vm : LinkViewModel var body: some View { VStack { if let metadata = vm.metadata { Text(metadata.title ?? "no title") Text(metadata.value(forKey: "_summary") as? String ?? "np description" ) } if let uiImage = vm.image { Image(uiImage: uiImage) .resizable() .frame(width: 100, height: 100) } } } } struct ContentView: View { var links = [ "https://www.google.com", "https://www.hotmail.com", "https://twitter.com/t3dotgg/status/1764398959513276630"] let metadataProvider = LPMetadataProvider() var body: some View { List(links, id:\.self) { item in Section{ VStack { Text(item) // Image(systemName: "heart.fill") MetadataView(vm: LinkViewModel(link: item)) } } } } } With no luck, I even tried the third party Swift OpenGraph libraires (getting the og:title), I printed the html with no luck, added user-agent and stuff and still can't. There was a great discussion on the mastodon github about it (for server side implementation) but replicated the iMessage behaviour seems hard. Any tips ? :-)
0
0
739
Mar ’24
How to get link preview (LPLinkMetadata) for Twitter post content like iMessage
In iMessage you can link a twitter post and it gets the image (if any), tweet content and title. Yet as a regular dev, I think, that we cannot get the tweet content like iMessage. From this Github issue of Mastodon, I know that in the header there is everything we need, yet in a simple swift code using LPLinkMetadata we cannot get the description. Here is the code below import SwiftUI import LinkPresentation class LinkViewModel : ObservableObject { let metadataProvider = LPMetadataProvider() @Published var metadata: LPLinkMetadata? @Published var image: UIImage? init(link : String) { guard let url = URL(string: link) else { return } metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in guard error == nil else { assertionFailure("Error") return } DispatchQueue.main.async { self.metadata = metadata } guard let imageProvider = metadata?.imageProvider else { return } imageProvider.loadObject(ofClass: UIImage.self) { (image, error) in guard error == nil else { // handle error return } if let image = image as? UIImage { // do something with image DispatchQueue.main.async { self.image = image } } else { print("no image available") } } } } } struct MetadataView : View { @StateObject var vm : LinkViewModel var body: some View { VStack { if let metadata = vm.metadata { Text(metadata.title ?? "no title") Text(metadata.value(forKey: "_summary") as? String ?? "np description" ) } if let uiImage = vm.image { Image(uiImage: uiImage) .resizable() .frame(width: 100, height: 100) } } } } struct ContentView: View { var links = [ "https://www.google.com", "https://www.hotmail.com", "https://twitter.com/t3dotgg/status/1764398959513276630"] let metadataProvider = LPMetadataProvider() var body: some View { List(links, id:\.self) { item in Section{ VStack { Text(item) MetadataView(vm: LinkViewModel(link: item)) } } } } } The twitter link doesn't return any description, I also tried third party OG libraries with the og:title in Swift with no success, yet it works on iMessage. Any tips ? :-)
0
0
871
Mar ’24
Issues using LinkPresentation's startFetchingMetadata (for: url)
I have a swiftUI app that displays rich link information. Am using LinkPresentation's startFetchingMetadata(for :url) to get back metadata. The code below works DispatchQueue.global(qos: .background).async {             self.metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in                 if let error {                     print("Error retrieving metadata:", error)                     self.metadataProvider.cancel()                     completion(false)                     return                 }                 guard let metadata else {                     print("Fetched metadata is nil?")                     self.metadataProvider.cancel()                     completion(false)                     return                 }                 DispatchQueue.main.async {                     self.metadata = metadata                     self.extractLinkMetadataImage()                     self.saveLinkMetadata()                     completion(true)                 }             }         } .. but displays the following messages in the Xcode console. Q1.) How do I remove the assertions error? I've already set Outgoing Network Connections in my App Group to Yes Q2.) How do I address the purple main thread warning. I've made sure both the startFetchingMetadata and imageProvider.loadObject calls are being made in DispatchQueue.global(qos: .background).async blocks. 2022-12-28 17:51:11.924604-0800 lrn[40432:8224366] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}> 2022-12-28 17:51:11.924760-0800 lrn[40432:8224366] [ProcessSuspension] 0x12201c120 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess Background Assertion' for process with PID=40438, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit} 2022-12-28 17:51:12.170643-0800 lrn[40432:8223670] [Security] This method should not be called on the main thread as it may lead to UI unresponsiveness. 2022-12-28 17:51:12.170826-0800 lrn[40432:8223670] [Security] This method should not be called on the main thread as it may lead to UI unresponsiveness. 2022-12-28 17:51:12.336358-0800 lrn[40432:8224255] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}> 2022-12-28 17:51:12.336405-0800 lrn[40432:8224255] [ProcessSuspension] 0x12201c120 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=40440, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit} 2022-12-28 17:51:12.336495-0800 lrn[40432:8223670] [ProcessSuspension] ProcessAssertion::remainingRunTimeInSeconds failed to get handle for process with PID=40440 Thanks
1
0
2.0k
Mar ’23
LPMetadataProvider Network Flow, LPLinkView Adherence to ToS
My team is currently evaluating using the LinkPresentation framework, but we have a couple questions. First, what is the network flow of the LPMetadataProvider? Does the provider call a metadata proxy hosted by Apple or does it make a direct request to the given URL? Second, does the LPLinkView adhere to the Terms of Service (ToS) of popular websites such as Facebook, YouTube and TikTok? Our team is currently working on implementing changes to our current solution to adhere to these and includes examples such as including the link to YouTube's Privacy Policy and ToS in the preview. We did not see these in the iMessage implementation and wanted to know if there is some type of agreement in place when using the framework.
0
0
1.1k
Aug ’22
LPMetadataProvider never returns in SFSafariExtensionHandler
I am creating a Safari App Extension for users to save web links and quotes to my app. I would like to cache web page metadata when links are saved by the extension. I am using a context menu command to capture information with the code below. override func contextMenuItemSelected( withCommand command: String, in page: SFSafariPage, userInfo: [String : Any]? = nil) { switch command { case "sendToApp": Task { guard let properties = await page.properties(), let pageURL = properties.url else { return }                 let provider = LPMetadataProvider()                 provider.timeout = 0.01                 os_log("*** Starting metadata call ***")                 let metadata = try? await provider.startFetchingMetadata(for: pageURL)                 os_log("*** Continued past metadata call ***") // ...             }         } I get the log: *** Starting metadata call *** LPMetadataProvider<1>: start fetching for URL ...but I am never seeing the log "*** Continued past metadata call ***" I wonder if the task is being killed for some reason? I thought maybe async code was an issue in SFSafariExtensionHandler, but the first await call in the guard passes successfully. I thought that the default timeout of 30s on LPMetadataProvider may be too great, but it still fails with a tiny timeout of 0.01s. I have added com.apple.security.network.client to the entitlements of the extension. Is there something I am missing please?
1
0
1.7k
Apr ’22
iMessage not recognizing OG tags on web page
When my site is being sent, the OG tags are being ignored. But if I use local host open graph checker, which rips the head from my page and send it they work. The Tags work on all other platform I've tested on (Android, Facebook messenger, Slack and twitter). The site is Next.js based. <meta property="og:title" content="Title here"> <meta property="og:image" content="URL to image here">
0
0
585
Oct ’21
Bug: Business name displayed incorrectly only in Location Share Preview (Apple Maps Metadata issue)
Hi everyone, I’m facing a very specific issue with our business location on Apple Maps. In the Apple Business Connect dashboard, our name is correctly set as "ANLOG Lojistik". It also appears correctly within the Apple Maps app itself. However, when we share the location via WhatsApp or iMessage, the "Preview Card" (Metadata) displays the name as "Anlog LojİStİK". It seems like a character rendering bug (specifically with Turkish character case sensitivity). Even standard characters like 'S' and 'K' are being forced into uppercase randomly. When you click the link, it opens correctly in Apple Maps, but the preview remains broken. Apple Support says "it's a 3rd party app issue," but this happens because the LPMetadataProvider fetches this specific data from Apple servers. Has anyone experienced a metadata sync/cache issue like this before? How can we force Apple to refresh the "Place Card" preview data?
Replies
0
Boosts
0
Views
156
Activity
May ’26
iMessage doesn't show the og:description meta header for share.google urls
When you share a Url from any Google product, it creates a share.google minify Url. When iMessage fetch the Url meta headers, it receives the og:title, og:url, og:site_name, og:image. But it only show the preview card with og:image, og:title, and og:site_name, ignoring the value of og:description.
Replies
0
Boosts
0
Views
70
Activity
Feb ’26
Why my link color changes back to system default on click and hold?
I currently have a custom UITextView that properly changes the color of a link to the custom color I have set, however, when I click and hold the link, and the animation plays that makes the link bigger and creates a boarder around the link before previewing the website, the link changes briefly back to the system default color, and when letting go, it changes back to my custom color. Is there anyway to have the link always be my custom color, even when clicking and holding? struct AutoDetectedClickableDataView: UIViewRepresentable { let text: String let dataDetectors: UIDataDetectorTypes @Binding var height: CGFloat private func dataDectectorValue(_ dataDectecor: UIDataDetectorTypes) -> UInt64 { var checkingTypes: [NSTextCheckingResult.CheckingType] = [] if dataDetectors.contains(.phoneNumber) { checkingTypes.append(.phoneNumber) } if dataDetectors.contains(.link) { checkingTypes.append(.link) } if dataDetectors.contains(.address) { checkingTypes.append(.address) } if dataDetectors.contains(.calendarEvent) { checkingTypes.append(.date) } if checkingTypes.isEmpty { return 0 } let intCheckingTypes: UInt64 = checkingTypes.reduce(0) { result, checkingType in UInt64(result) | UInt64(checkingType.rawValue) } return intCheckingTypes } func makeUIView(context: Context) -> UITextView { let textView = UITextView() textView.dataDetectorTypes = dataDetectors textView.isEditable = false textView.isScrollEnabled = false textView.backgroundColor = .clear textView.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0), compatibleWith: textView.traitCollection) textView.textColor = UIColor.label textView.adjustsFontForContentSizeCategory = true textView.textContainer.lineBreakMode = .byWordWrapping textView.textContainerInset = .zero textView.textContainer.lineFragmentPadding = 0 textView.translatesAutoresizingMaskIntoConstraints = false textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) textView.setContentHuggingPriority(.defaultHigh, for: .horizontal) textView.linkTextAttributes = [.foregroundColor: JeromesColors.UILinkColor] textView.tintColor = JeromesColors.UILinkColor for gesture in textView.gestureRecognizers ?? [] { if gesture is UITapGestureRecognizer { gesture.view?.tintColor = JeromesColors.UILinkColor } } return textView } func updateUIView(_ uiView: UITextView, context: Context) { let font = UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0), compatibleWith: uiView.traitCollection) let color = UIColor.label let attributed = NSMutableAttributedString(string: text, attributes: [ .font: font, .foregroundColor: color ]) let detectorValue = dataDectectorValue(dataDetectors) var matchCount = 0 if !dataDetectors.isEmpty, detectorValue != 0 { let detector = try? NSDataDetector(types: detectorValue) detector?.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count)) { match, _, _ in guard let match = match else { return } if match.resultType == .date, let date = match.date, date < Date() { return } else { attributed.addAttributes([ .foregroundColor: JeromesColors.UILinkColor, .underlineStyle: NSUnderlineStyle.single.rawValue, ], range: match.range) matchCount += 1 } } } uiView.attributedText = attributed if matchCount == 0 { uiView.isSelectable = false } else if matchCount > 0 { uiView.isSelectable = true } DispatchQueue.main.async { uiView.layoutIfNeeded() let fittingSize = CGSize(width: uiView.bounds.width, height: .greatestFiniteMagnitude) let size = uiView.sizeThatFits(fittingSize) height = size.height } } }
Replies
0
Boosts
0
Views
199
Activity
Aug ’25
NSItemProvider iconProvider has a dynamic type rather than an image type
I'm using a LPMetadataProvider to get metadata for URLs. If I do this if itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier) { let item = try? await itemProvider.loadItem(forTypeIdentifier: UTType.image.identifier) // continue with code to convert data to UIImage... } That seems to fail quite often, even on larger sites like Amazon where users will expect to see an icon. I've noticed it's because sometimes the type is dyn.agq80w5pbq7ww88brrfv085u I'm assuming this is because something about the website response or the image data does not let the system determine if it is actually an image. If I just do this let type: String = "dyn.agq80w5pbq7ww88brrfv085u" if itemProvider.hasItemConformingToTypeIdentifier(type) { let item = try? await itemProvider.loadItem(forTypeIdentifier: type) // continue with code to convert data to UIImage... } Then I get the icon, so it is there and it is an image. The problem is, does this dynamic type cover everything? Should I even be doing that? Does anyone know precisely what causes this and are there recommendations on better ways to handle it? I know LPLinkView appears to do something to load these 'non-image' icons so I am assuming there are way. My assumption is that it would be safe to look at the results of itemProvider.registeredTypeIdentifiers() and if it has something use that as the type rather than coming up with a hardcoded list of types to check for.
Replies
2
Boosts
0
Views
1.1k
Activity
Jun ’24
How to get link preview (LPLinkMetadata) for Twitter post content like iMessage
In iMessage when you link a twitter post you have the following preview As you can see the content of the tweet is present. I wanted to replicate that so I used LPLinkMetadata and even found the "hidden" metadata.value(forKey: "_summary") to get the description. Below is the full code import SwiftUI import LinkPresentation class LinkViewModel : ObservableObject { let metadataProvider = LPMetadataProvider() @Published var metadata: LPLinkMetadata? @Published var image: UIImage? init(link : String) { guard let url = URL(string: link) else { return } metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in guard error == nil else { assertionFailure("Error") return } DispatchQueue.main.async { self.metadata = metadata } guard let imageProvider = metadata?.imageProvider else { return } imageProvider.loadObject(ofClass: UIImage.self) { (image, error) in guard error == nil else { // handle error return } if let image = image as? UIImage { // do something with image DispatchQueue.main.async { self.image = image } } else { print("no image available") } } } } } struct MetadataView : View { @StateObject var vm : LinkViewModel var body: some View { VStack { if let metadata = vm.metadata { Text(metadata.title ?? "no title") Text(metadata.value(forKey: "_summary") as? String ?? "np description" ) } if let uiImage = vm.image { Image(uiImage: uiImage) .resizable() .frame(width: 100, height: 100) } } } } struct ContentView: View { var links = [ "https://www.google.com", "https://www.hotmail.com", "https://twitter.com/t3dotgg/status/1764398959513276630"] let metadataProvider = LPMetadataProvider() var body: some View { List(links, id:\.self) { item in Section{ VStack { Text(item) // Image(systemName: "heart.fill") MetadataView(vm: LinkViewModel(link: item)) } } } } } With no luck, I even tried the third party Swift OpenGraph libraires (getting the og:title), I printed the html with no luck, added user-agent and stuff and still can't. There was a great discussion on the mastodon github about it (for server side implementation) but replicated the iMessage behaviour seems hard. Any tips ? :-)
Replies
0
Boosts
0
Views
739
Activity
Mar ’24
How to get link preview (LPLinkMetadata) for Twitter post content like iMessage
In iMessage you can link a twitter post and it gets the image (if any), tweet content and title. Yet as a regular dev, I think, that we cannot get the tweet content like iMessage. From this Github issue of Mastodon, I know that in the header there is everything we need, yet in a simple swift code using LPLinkMetadata we cannot get the description. Here is the code below import SwiftUI import LinkPresentation class LinkViewModel : ObservableObject { let metadataProvider = LPMetadataProvider() @Published var metadata: LPLinkMetadata? @Published var image: UIImage? init(link : String) { guard let url = URL(string: link) else { return } metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in guard error == nil else { assertionFailure("Error") return } DispatchQueue.main.async { self.metadata = metadata } guard let imageProvider = metadata?.imageProvider else { return } imageProvider.loadObject(ofClass: UIImage.self) { (image, error) in guard error == nil else { // handle error return } if let image = image as? UIImage { // do something with image DispatchQueue.main.async { self.image = image } } else { print("no image available") } } } } } struct MetadataView : View { @StateObject var vm : LinkViewModel var body: some View { VStack { if let metadata = vm.metadata { Text(metadata.title ?? "no title") Text(metadata.value(forKey: "_summary") as? String ?? "np description" ) } if let uiImage = vm.image { Image(uiImage: uiImage) .resizable() .frame(width: 100, height: 100) } } } } struct ContentView: View { var links = [ "https://www.google.com", "https://www.hotmail.com", "https://twitter.com/t3dotgg/status/1764398959513276630"] let metadataProvider = LPMetadataProvider() var body: some View { List(links, id:\.self) { item in Section{ VStack { Text(item) MetadataView(vm: LinkViewModel(link: item)) } } } } } The twitter link doesn't return any description, I also tried third party OG libraries with the og:title in Swift with no success, yet it works on iMessage. Any tips ? :-)
Replies
0
Boosts
0
Views
871
Activity
Mar ’24
Question about importing news stories into app
I'm looking to create an app that displays news stories from other sites, such as CNN, NYT, or more. Will credit them, but is there any type of API/tools I can use to import them directly into my app without linking them to safari, such as in Apple News?
Replies
0
Boosts
0
Views
800
Activity
Jul ’23
Issues using LinkPresentation's startFetchingMetadata (for: url)
I have a swiftUI app that displays rich link information. Am using LinkPresentation's startFetchingMetadata(for :url) to get back metadata. The code below works DispatchQueue.global(qos: .background).async {             self.metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in                 if let error {                     print("Error retrieving metadata:", error)                     self.metadataProvider.cancel()                     completion(false)                     return                 }                 guard let metadata else {                     print("Fetched metadata is nil?")                     self.metadataProvider.cancel()                     completion(false)                     return                 }                 DispatchQueue.main.async {                     self.metadata = metadata                     self.extractLinkMetadataImage()                     self.saveLinkMetadata()                     completion(true)                 }             }         } .. but displays the following messages in the Xcode console. Q1.) How do I remove the assertions error? I've already set Outgoing Network Connections in my App Group to Yes Q2.) How do I address the purple main thread warning. I've made sure both the startFetchingMetadata and imageProvider.loadObject calls are being made in DispatchQueue.global(qos: .background).async blocks. 2022-12-28 17:51:11.924604-0800 lrn[40432:8224366] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}> 2022-12-28 17:51:11.924760-0800 lrn[40432:8224366] [ProcessSuspension] 0x12201c120 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess Background Assertion' for process with PID=40438, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit} 2022-12-28 17:51:12.170643-0800 lrn[40432:8223670] [Security] This method should not be called on the main thread as it may lead to UI unresponsiveness. 2022-12-28 17:51:12.170826-0800 lrn[40432:8223670] [Security] This method should not be called on the main thread as it may lead to UI unresponsiveness. 2022-12-28 17:51:12.336358-0800 lrn[40432:8224255] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}> 2022-12-28 17:51:12.336405-0800 lrn[40432:8224255] [ProcessSuspension] 0x12201c120 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=40440, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit} 2022-12-28 17:51:12.336495-0800 lrn[40432:8223670] [ProcessSuspension] ProcessAssertion::remainingRunTimeInSeconds failed to get handle for process with PID=40440 Thanks
Replies
1
Boosts
0
Views
2.0k
Activity
Mar ’23
Play videos using LPLinkMetaData's videoProvider and AVPlayer
I want to be able to play videos using LPLinkMetaData's videoProvider and AVPlayer. How should I implement this?
Replies
1
Boosts
0
Views
1.1k
Activity
Oct ’22
LPMetadataProvider Network Flow, LPLinkView Adherence to ToS
My team is currently evaluating using the LinkPresentation framework, but we have a couple questions. First, what is the network flow of the LPMetadataProvider? Does the provider call a metadata proxy hosted by Apple or does it make a direct request to the given URL? Second, does the LPLinkView adhere to the Terms of Service (ToS) of popular websites such as Facebook, YouTube and TikTok? Our team is currently working on implementing changes to our current solution to adhere to these and includes examples such as including the link to YouTube's Privacy Policy and ToS in the preview. We did not see these in the iMessage implementation and wanted to know if there is some type of agreement in place when using the framework.
Replies
0
Boosts
0
Views
1.1k
Activity
Aug ’22
LPMetadataProvider never returns in SFSafariExtensionHandler
I am creating a Safari App Extension for users to save web links and quotes to my app. I would like to cache web page metadata when links are saved by the extension. I am using a context menu command to capture information with the code below. override func contextMenuItemSelected( withCommand command: String, in page: SFSafariPage, userInfo: [String : Any]? = nil) { switch command { case "sendToApp": Task { guard let properties = await page.properties(), let pageURL = properties.url else { return }                 let provider = LPMetadataProvider()                 provider.timeout = 0.01                 os_log("*** Starting metadata call ***")                 let metadata = try? await provider.startFetchingMetadata(for: pageURL)                 os_log("*** Continued past metadata call ***") // ...             }         } I get the log: *** Starting metadata call *** LPMetadataProvider<1>: start fetching for URL ...but I am never seeing the log "*** Continued past metadata call ***" I wonder if the task is being killed for some reason? I thought maybe async code was an issue in SFSafariExtensionHandler, but the first await call in the guard passes successfully. I thought that the default timeout of 30s on LPMetadataProvider may be too great, but it still fails with a tiny timeout of 0.01s. I have added com.apple.security.network.client to the entitlements of the extension. Is there something I am missing please?
Replies
1
Boosts
0
Views
1.7k
Activity
Apr ’22
iMessage not recognizing OG tags on web page
When my site is being sent, the OG tags are being ignored. But if I use local host open graph checker, which rips the head from my page and send it they work. The Tags work on all other platform I've tested on (Android, Facebook messenger, Slack and twitter). The site is Next.js based. <meta property="og:title" content="Title here"> <meta property="og:image" content="URL to image here">
Replies
0
Boosts
0
Views
585
Activity
Oct ’21