NITHIN SHAHRUKH NITHIN SHAHRUKH - 4 months ago 28
Objective-C Question

How to take the parameter from URL scheme.

I am using URL scheme in my iPhone app,from a page I switch user to safari,and a button click from Web page,I am reverting back to app
At that time ,some parameters are passed by the web page like

myapp://parameter=1


How can I find this parameter from my app ?
I have placed a break point in

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)ur


but while revert back.it is not get called.

Answer

You can use this url host to find out the parameters, where parameters could be of any kind, anything after http:// or custom tag custom:// will be caught in the following code

 NSString *urlParameter = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

If you have multiple parameters then you could use componentsSeparatedByString method to separate the parameters