Kiwi Kiwi - 5 months ago 33
Android Question

Deep linking href in pdf

I have a deep link that works when in the chrome browser to open my app with a certain ID. This link looks like following:

intent://m/#Intent;scheme=myapp://app.com/reference/2016062910185811;package=some.package.com;end


this works when in a webbrowser via
<a href="intent://...;end">click</a>
.

But when setting this link in a PDF (via aspose) this doesn't do anything, although it recognizes that it is a link (I can see the click animation).

The link is set via the following code::

var img = new Aspose.Pdf.Generator.Image(sec1);
tr.Paragraphs.Add(img);

//Assign a new instance of hyperlink to hyperlink property of segment
img.Hyperlink = new Hyperlink {
LinkType = HyperlinkType.File,
Url = "intent://m/#Intent;scheme=myapp://app.com/reference/" + input.Reference + ";package=some.package.com;end"
};

Answer

Non-standard URL schemes (which is what intent:// is, literally) aren't always treated as links. It sounds like the PDF viewer you're using isn't set up to recognize them correctly, and even if it were, the link would be broken anywhere except on Android devices.

Your best option is to somehow wrap that URL inside a link that the PDF viewer CAN recognize (http:// or https://), and then take care of opening your app later, usually by way of some sort of automatic redirect. This is how we handle things at Branch.io, to make sure the app always launches no matter where the link is opened.