If a UIWebView displays a remote page with a username/password then can the native code tell if/when it has been validated? - ios

I have a requirement for an app to communicate with a server, this communication is done using a proprietary http based protocol and the app uses NSUrlConnection for this.
However before the app can be used the user must first perform a one-off registration, and the requirement is that this is done by them logging onto a web page which will be downloaded and displayed in a UIWebView. As a UIWebView is used I no longer have access to the HTTP header/body nor the NSURLConnectionDelgate etc. for this part of things.
My question is, how can the app know if and when the user has successfully logged onto the web site?

It sounds like you want to implement some code in the connection:didReceiveAuthenticationChallenge: method of the NSURLConnectionDelegateProtocol. There's more information about how to respond to a challenge here.

Related

Can I perform a task in Main iOS app from the app Extension?

I have an app extension for Sharing (Share Extension) and when a user selects my app to share an image, my app will send that image to a server.
The problem is that the server requires an authenticated identity (AWS Cognito) to send the object to the server. Since I cannot share Authentication from my main app to my extension and I don't want to have the user sign in every time they want to share, I'm stuck.
I can see this being done with messaging apps where a user sends a message from a share extension. I'm not sure how they achieve this. Since the user is not asked to login again in the extension, somehow the credentials are either being shared with the extension or the app is momentarily launched to perform that upload while remaining in the background (not sure this is possible).
So my question is what is the approach I should be using. Should the extension somehow be directing the main app to upload the image or should I figure a way of sharing the access tokens with the extension in a secure way and accessing them without any user action?
The solution is to setup a shared container for the app & the extension, please see "Sharing data with your containing app" section in this article: https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#:~:text=To%20enable%20data%20sharing%2C%20use,App%20to%20an%20App%20Group.

It is possible to transfer data to browser from application

I want to get back some response to browser from application.
Like if I come into application from browser to application using deeplinking then I handle some changes into application and I want to retrive those changes into browser from application.
So help me how it is possible.
That's not possible. What you can do if you need to interact with a web site is to present the user a web view inside your app. That's actually a good practice since you don't send the user outside of your app.
The web view has some delegate methods were you can catch requests and linking.
You can deal with URL schemes by adding them in your website and make your app handle them. You can pass information in the URL and retrieve it in your app by parsing the URL.

Application inside another application in iOS

How do you import or display an application inside another application?
It is like, it will be a part of the app where you can use it's functionalities. Maybe in full screen or not in full screen. My thoughts are these are web based and is being opened in a UIWebView to use the functionalities.
Extensions? It's more like "piggybacking".
Here's an example:
https://hub.united.com/en-us/news/web/pages/uber-on-the-united-app.aspx
I'll post an answer regrouping my answer and also #Popeye one that seems valid too.
There may be a few ways to do it, each ones of them may act differently.
The other app offers a public SDK/API/WebServices
As an example, I'll take FaceBook API, that allow you to login giving you a UIViewController (that you can customise), and allowing you to ask for some data through their WebServices (like who are the friends, etc.). You're still inside your app.
The other app offers you a private SDK/API/WebServices
Same as the other one, but it more like a parternship. You're still inside your app.
URL Schemes
The other app gives you a few way to interact with it. They check if the app is installed, and launch it with some parameters, or if not, they may redirect it to the app in the Store, their website, etc. More info about URL Schemes from Apple Doc. You have to check their documentaion to know how to interact with it.

How to share links via FB App when I am offline

I am developing an mobile app for iPhone. The app will primary used by people who are on holiday in a different country and will be offline most of the time, due to high costs for internet traffic.
However, the company for which I am developing the app wants to users to be able to use the "Facebook Share" functionality also when people are not connected to the internet.
It should work on a way that they click the SHARE link button in the app, but then get a message that they are offline and the link will get shared as soon as they are online again.
I am trying to figure out how to do this. Can I pass the link I want to share to the official FB App via fb:// protocol (or whatever) and the FB App handles the post/share as soon as it is online again?
Or do I have to do it on my own, put the links I want to share in a internal database and then post them to the wall when I am online again?
Or any other ways??
Any suggestions would be welcome, I would prefer a very quick solution and hope someone maybe has an idea how to do this. I was hoping I can pass the share-link to the official FB App and this one handles everything when it goes online again !?
Thanks for your ideas!
Your approach should be to make your link-sharing code automatically cache requests until they are sent. The app then doesn't need to concern itself with the details - it can just post the link and get a 'failed', 'success', or 'postponed' response from your API and notify the user accordingly.
Your link-sharing code can then internally check if it can currently post to FB and if not (either because the user is currently offline or perhaps the Facebook token is expired) it will store it for later. This class will then re-check periodically (for example when the app comes to the foreground or when the class is initialised the next time the app starts) for connectivity and then it will check if the token is still valid and perform FB login if required. Once it has a valid token it can then iterate through the pending requests and act upon them.
If you really want to make it nice and clean, you can separate out the code that accepts incoming requests to do something, checks if it can be performed now, does it or stores it for later, and periodically checks any requests in the pending queue. This class will not have any idea what the requests do or how they are performed, it will work with another class that implements a protocol to do the actual work and knows about facebook, etc. There may even be an existing design pattern for such a setup, but I don't know what it's called if there is.
Update: I did some research and found this is very similar to the "Fire-and-Forget Pattern".

Can we get any result or feedback when launched a link in UIWebview within an ipad application

I developed an ipad app where in i have a situation where the user taps a button which redirects to a login page (UIWebView),The user enters his credentials and web page hits a server where the validation takes place and the browser is returned a feed back string (authorization).
Question:
Is there a provision to know the feedback string/data by the application? According to my knowledge as soon as a webView is launched our application has no info about the happenings on Webview.
I don't want to implement services in my application since the service provider says that the webpage redirects the user to app upon successful login.Which may be possible on a desktop,but in ipad application can the bowser/Webview redirect back to the application upon login and more ever i need the feedback string in my application.Can some one suggest how could i implement the same.Please correct me if i am going wrong...
TNQ
You can call Objective-C methods from UIWebView. This you can do by trapping your custom urls in the shouldStartLoadWithRequest: method. More details are here.

Resources