I'm sending the user from my app to a browser then returning them to the app through my custom URL. The problem is: All of my instance variables are empty once I return! The interface is preserved (as expected since I used the Storyboard), but the values (of the textfields, instance variables, etc.) are inaccessible...they return null.
What's going on??
A URL scheme allows you to launch a native iOS application from another iOS app or a web application. You can set options in the URL that will be passed to the launched application.
The app: URL scheme can be used by packaged applications to obtain resources that are inside a container. These resources can then be used with web platform features that accept URLs.
Custom URL schemes provide a way to reference resources inside your app. Users tapping a custom URL in an email, for example, launch your app in a specified context. Other apps can also trigger your app to launch with specific context data; for example, a photo library app might display a specified image.
(It's been a while since I had this problem, but here's what I think happened…)
While handling the return URL's call in my app delegate's openURL method, I attempted to call my view controller's method in response and did so by creating an instance of that method's view controller. Since I didn't access the current instance, I essentially created a blank, second instance of that view controller.
In this case, I ended up using an NSNotification
instead of directly calling the method. And I definitely think this is the most elegant solution.
But what I also could have done in retrospect, is access the current instance of the view controller which also happened to be the root view controller using:
UIViewController *controller = self.window.rootViewController;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With