3

The application i'm working on requires me to launch the application from any webpage so it can rip the text from that webpage via stringByEvaluatingJavascriptFromString (which requires the url).

How do you launch an application from mobile safari from any webpage?

In addition would it be possible to access the url of the current webpage from the app whilst doing this?

The current method i'm using requires one to copy/paste the url directly into the app.

From what I've seen so far it can be done via bookmarks but i'm not sure about how the code would work.

Charles
  • 493
  • 7
  • 14
  • 1
    Please elaborate your question correctly I am not able to get what you actually require. I guess what you need to do is URL http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html – Mrunal Feb 19 '12 at 11:19

1 Answers1

4

You can register your app to a custom URL scheme (See: How to register an app to respond to a custom URL scheme opening request?). When a URL with this scheme is opened in Mobile Safari, your app delegates application:didFinishLaunchingWithOptions: method will be called. The URL will be passed in the options dictionary as UIApplicationLaunchOptionsURLKey.

Now you can create a bookmark in Mobile Safari, which opens your app and passes the URL along:

javascript:window.location="yourAppURLScheme://?url="+window.location
Community
  • 1
  • 1
  • @Charles This JavaScript code is a bookmarklet, which you can paste in a Mobile Safari bookmark. When you later select this bookmark, the JavaScript code gets executed and launches your app with the current URL as parameter. – Yannick Reifschneider Feb 20 '12 at 16:11