Http://blog.csdn.net/ba_jie/article/details/6884818
The iPhone SDK can bind your app to a custom URL scheme. This URL scheme can be used to start your app from a browser or another app.
It is up to you to decide how to respond to the URL Scheme Application sent to you from another app: you can wake up your app or send some information to you.
It is very easy to register a URL scheme for your app. It is OK to define two key values in the info. plist file. As shown in:
- Add a key value called URL types.
- Add a URL identifier to item 1 in the format of Reverse Domain Name: COM. mycompany. MyApp.
- Add a URL scheme and define a value for it, any string. For example, MyApp.
After the definition ends, you can use the following mode to send a URL:
MyApp ://
MyApp: // some/path/here
MyApp ://? Foo = 1 & amp; bar = 2
MyApp: // some/path/here? Foo = 1 & amp; bar = 2
Then, your app's uiapplicationdelegate will receive a message. If you want to process the URL by yourself, you can reload the following method:
[Plain] View
Plaincopy
- -(Bool) Application :( uiapplication *) Application handleopenurl :( nsurl *) URL
-
- {
- // Do something with the URL here
-
- }
For example, save the uploaded URL locally:
[Plain] View
Plaincopy
-
- -(Bool) Application :( uiapplication *) Application handleopenurl :( nsurl *) URL
- {
-
- If (! URL)
- {
-
- Return no;
- }
-
- Nsstring * urlstring = [url absolutestring];
-
- [[Nsuserdefaults standarduserdefaults] setobject: urlstring forkey: @ "url"];
- [[Nsuserdefaults standarduserdefaults] synchronize];
-
- Return yes;
- }
-