Applink

Pasquale Mirtuono's Avatar

Pasquale Mirtuono

17 Feb, 2016 11:15 AM

Hi,

i'm an iOS developer and i'm looking inside the demo app. I'm working on a project that include pdf with applinks (like appname://action?parameter). I try to open my pdf in your demo app that contains working applink using UIWebview. The FastPdfKit Viewer don't recognize the link.
Could you give me any support?

  1. Support Staff 1 Posted by Matteo on 17 Feb, 2016 02:29 PM

    Matteo's Avatar

    Hello,
    overriding documentViewController:didReceiveURIRequest: in a ReaderViewController subclass will be enough, most of the time.
    For example, given a custom URL with scheme appname, we can do something like this:

    -(BOOL)documentViewController:(MFDocumentViewController *)dvc didReceiveURIRequest:(NSString *)uri {
    if([uri hasPrefix:@"appname://"]) {
    [[UIApplication sharedApplication] openURL:myURL];
    } else {
    [super documentViewController:dvc didReceiveURIRequest:uri];
    }
    }
    
  2. Support Staff 2 Posted by Matteo on 17 Feb, 2016 04:56 PM

    Matteo's Avatar

    To integrate the above.

    1. Create your own ReaderViewController subclass

      @interface ApplinkReaderViewController : ReaderViewController


      @end @implementation ApplinkReaderViewController


      @end
    2. Override documentViewController:didReceiveURIRequest: in the implementation.

      @implementation ApplinkReaderViewController
      -(BOOL)documentViewController:(MFDocumentViewController *)dvc didReceiveURIRequest:(NSString *)uri {
      if([uri hasPrefix:@"appname://"]) {
      [[UIApplication sharedApplication] openURL:myURL];
      } else {
      [super documentViewController:dvc didReceiveURIRequest:uri];
      }
      }
      @end
      
    3. In your application, in place of ReaderViewController, use ApplinkReaderViewController

      MFDocumentManager * document = ... // Obtain MFDocumentManager
      //ReaderViewController * controller = [[ReaderViewController alloc]initWithDocument:document]; // OLD implementation
      ApplinkReaderViewController * controller = [[ApplinkReaderViewController alloc]initWithDocument:document];
      [self presentViewController:controller animated:YES]; // Continue as before
      

    Nota that for this to work, some other application installed on the device must have registered itself to handle the appname protocol. For example, you can open facetime://[email blocked] because FaceTime is installed.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac