How to Detect if WebView is showing a specific Website on iPhone - iphone

I am new in iOS development and trying to make a button called backhome which is only visible when the user tap on the changes the native Website I set in the loadRequest.
Now my question: Is there any way to detect if the user leaves the website I set for e.g in a if statement?

Set a delegate for your "UIWebView" object and then write a method to respond to:
webView:shouldStartLoadWithRequest:navigationType:
The request parameter in that call has a URL and from there, you can tell if the user has left your default website.

Related

Facebook App: Nothing happens when trying to add domain

I've made a Facebook app to implement fecebook login on my php Saas solution.
I can't add a domain in the settings->advanced section.
A dialog is shown. I write the domain and click the [add] button. Now a spinner is showing and just keeps spinning. I've tried everal computers and mobile devices. It is the same everywhere.
What do I do wrong?
I have set the domains in then settings -> basic sections and I have added all the url callbacks.
image af dialog with spinning button - with protocol
EDIT: It is the same thing with or without protocol. The placeholder in the field states to enter an URL but either with or without the protocol part nothing happens.
image af dialog with spinning button - without protocol

How to send sms, detecting text in textview?

I want that when user clicks on certain text,(like call, sms, mail), then corresponding activity should happen ie, when user clicks on call then an action sheet should appear with actions whether you want to save or call etc, similarly for sms and mail.I used textview and gave detection for numbers and email. So for call and mail it is working fine. But how to detect for sms?Because when I give number detection it will automatically show call action sheet ie save or call or cancel.But I want following action sheet, which sms, open, copy, cancel:
I tried using sms//"91123456", but it is not working. I know I can directly launch message picker but do not want this, I want to show default action sheet.I tried this in html and it is working but I want to do in native.
Did you try textView.dataDetectorTypes = UIDataDetectorTypeAll;?
For more data detector types see this UIKit Data Types Reference.

Is it possible to call a URL without a visible view?

Is it possible to load a URL without a visible view?
Basically I'm trying to submit some information to my server by a php page. It works from my webViewController, which has a working view, but not from my appDelegate, which doesn't have a visible view.
I recommend you use ASIHTTPRequest to submit the information to your php page.

How to push a view from a web page?

Suppose my app will load a local web page which is stored in my app bundle. I want to push the view or present a view when the user click a link or an image inside that web page. How to do this? Let's make this be general question: how to communicate with my app from a local web page?
Thank you.
Use "webview.request.URL.absoluteString" to get the request-string of the clicked link in the delegate-method "webViewDidFinishLoad:" or "webViewDidStartLoad:".
then you can scan this url for some special substring.
For example you could make a link like ".../index.php?iPhone_action=abcdef".
In the delegate-methods you can check if the link has the substring "?iPhone_action=" and if it does, then put the part of the link, whick follows "?iPhone_action=" in a NSString.
(in our example it would be "abcdef").
Depending on the value of this NSString you could fire a action in your app.
There is an undocumented method to catch the event when you click on a link in UIWebView. You can do whatever you want to do in that method.Search on google/stackoverflow for it. Or see my answer in this stackoverflow post.
Show alert view when click on a link

UIDataDetectorTypeAll and popup in app (or at least ask before switching)

Hey guys, I've recently implemented a UITextView into my app, and activated UIDataDetectorTypeAll. Everything works perfect, except when users click on the link, phone number, etc. it automatically kicks them out of my app and into the website, etc. Is there any way to have the website appear in my own app in a custom view, or at least have a popup that asks the user if they want to be taken to the website, call, etc?
Thank you!
Use a UIWebView and message it to load the URL. Wait, that's no help, sounds like you need to intercept the link so you can know the URL. The UITextView may be calling UIApplication's openURL function. This is ugly, but what if you replaced that openURL with your own using categories or subclassed UIApplication and added your own openURL function to override the one at the UIApplication level. Once there, you have a chance to intercept the call and direct it to your own UIWebView or at least pop up a UIAlertView.