Using iOS Link Presentation Framework with Xamarin Forms

Link presentation is a framework that is added with iOS 13 and already used in its native applications. With this library, developers can now customize when viewing rich URLs in their own applications.

Apple is already using this library, so as an end user we have come across it in messages app or other applications.

In order to get this in our application, the Open Graph tags must be set properly on the websites we will use. For instance, if we view the source code of this blog post, we’ll see the following tags:

To retrieve and use these assigned metadata, we can use the LPMetadataProvider class of the LinkPresentation library. The content of this class is as follows:

class LPMetadataProvider An object that retrieves metadata for a URL.

class LPLinkMetadata An object that contains metadata about a URL.

class LPLinkView A rich visual representation of a link.

struct LPError An error returned by the LinkPresentation framework.

We can use this framework in our Xamarin Forms project. To do this, we first create a control in the Portable project that includes a bindable Url property inherited from View control:

Then we must create an LPLinkView and assign the LPLinkMetadata object to this view to display previews of links assigned with this Url property. To do this, we need to create a Custom Renderer.

In StartFetchingMetadata, you can control and modify metadata from the server. In fact in here, pictures, videos, text can be added if the pages are not available, or the description text can be translated into the desired language.

Our page’s XAML is like below:

As a result, we get this screen:

You can download sample app from here. And some useful readings:

Leave a Reply

Your email address will not be published. Required fields are marked *


#CastlevaniaNetflix’de 2.sezonu bitirdim ve dracula’yı haklı buluyorum. sumeyyaarar photo

Meraklısı var ise:
OrderBy(), QuickSort ile yazılmıştır ve complexity'si O(nlogn)'dir.

Demliğin içine filtre kahve kağıdı koymak sumeyyaarar photo

#stackoverflow dark mod trend'ine uyum sağlamış, sunumu da çok iyi 🌑 sumeyyaarar photo