Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect back to app in url scheme with Xcode 6.0.1

Tags:

ios

I am Working on a app in which there is a Registration field. When Registration is done successfully I get a confirmation mail. When I Confirm the link then I want to navigate back to my app using URL Schemes. How Can I achieve this.

Thanks.

like image 541
Avinash651 Avatar asked Jan 23 '15 12:01

Avinash651


People also ask

How do I add a URL type in Xcode?

Register your scheme in Xcode from the Info tab of your project settings. Update the URL Types section to declare all of the URL schemes your app supports, as shown in the following illustration. In the URL Schemes box, specify the prefix you use for your URLs.

How do you add a URL scheme?

For this, just Open Xcode, go to Project Settings -> Info, and add inside 'The URL Types” section a new URL scheme. Add something of the sort of com. globalApp and that's it. Now install your app, open the browser type com.


Video Answer


2 Answers

  1. Go into your app's info.plst file.
  2. Add a Row to this and call it "URL types".
  3. Expand the first item in "URL types" and add a row called "URL identifier", the value of this string should be the reverse domain for your app e.g. "com.yourcompany.myapp".
  4. Again, add a row into the first item in "URL types" and call it "URL Schemes".
  5. Inside "URL Schemes" you can use each item as a different URL you wish to use, so if you wanted to use "myapp://" you would create an item called "myapp".

Using the URL scheme, you've now registered the URL with the app. You can start the application by opening a URL with the custom scheme.

Use UIApplicationDelegate if you want to provide a custom handler for it. All you need to do is provide an implementation for it in your delegate.

Then get it:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
  if (!url) { 
    return NO; 
  } 
  // Do something with the url here 
}

Refer to this.

like image 123
Sport Avatar answered Oct 26 '22 04:10

Sport


In the project target, go to the Info tab and add a URL types in the URL Schemes field - let's say "myApp". Then, the email should contain a link like: myApp://something and your app will be launched. Best practice would require that you actually check that "something" and show the user a "confirmation" message.

like image 36
tagyro Avatar answered Oct 26 '22 04:10

tagyro