post redirected url accessed by objective-c message
I wanted to know if it is pos开发者_开发问答sible and if so how to know the url you are accessing via objective-c takes you to the correct webpage. To elaborate further:
If a user is using an app that connects to a webpage to get it's data, and if this user is say at an airport. The internet connection at airport in many cases will redirect u to their webpage (regardless of what url u maybe type) where u have to either pay or something to get any further internet access. Thus if a app needing data from a webpage is used without user's knowledge of this limited access to internet, i want to display a popup message that informs the user saying something that the webpage it tried to access was required to a different webpage thus cannot access data. As oppose to getting false data and the user thinking the app is buggy.
Is there a way to do this. Thanks in advance for all of your help.
If you are using NSURLConnection
you can implement the NSURLConnectionDelegate
method
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
which is called if it is determined that the request must redirect to a new location. The delegate can the choose to allow the redirect, modify the destination, or deny the redirect.
You can read more about NSURLConnectionDelegate
and its methods here
精彩评论