简体   繁体   中英

How to open Safari (or Adobe, or any other app) to a specific webpage or document using a URL link from within my custom iOS application?

I am working with a custom iOS iPad application.

Every application in iOS can be treated as a web server (so to speak).

All over the net, I see that you can "call" Twitter from another app by using a hyperlink including "twitter://". What about other applications? Where is a repository from which to learn this information?

I want to use Safari and Adobe. Do I use safari://, or acrobat://?

Note: If you reply to this question by using any Code other than HTML or plain hyperlinks, you are completely wasting your time, my time, and anyone's time who will read your answer at a later date. Many people have asked this question only to get a whole bunch of great answers from smart people...only that the answers do not AT ALL match the question.

To open a web page in Safari, just use the openURL: function:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];

With Adobe, things are a little more complicated. I couldn't find a public URL scheme, so I downloaded the Adobe Reader app and looked at its Info.plist file. I found its URL scheme to be com.adobe.Adobe-Reader .

// I'm using a local file here, but it should also work with any remote PDF files
NSString *path = [[NSBundle mainBundle] pathForResource:@"SomeFile" ofType:@"pdf"];

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"com.adobe.Adobe-Reader://%@", path]];

// Check to see if the user has Adobe Reader installed
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    // Reader is installed, open the PDF
    [[UIApplication sharedApplication] openURL:url];
}

So your "plain hyperlinks" are http://www.google.com and com.adobe.Adobe-Reader:// .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM