Opening a custom url link in Safari/GMail - iphone

I am sending a custom url scheme link inside an email:
[body appendString:#"<div><button type=\"button\">Open in App</button></div>"];
This successfully adds a button in the email I am sending which, when tapped, opens my app (if it is installed).
This works fine when I open the email in mail.app on the iOS device, but doesn't do anything when I open the mail in Gmail (both via Safari and the native GMail app).
Is this a limitation of the framework? Or should safari be able to recognize these links?

The best solution I've found for this is to link to a PHP script on a web server that takes parameters and redirects the request to your custom URL scheme within Safari.
This link will be in the email:
http://myserver.com/_script.php?parameter=one
This then redirects to:
myappscheme://open/?parameter=one
It does mean you have to open Safari to process the link, but given that you're opening the link from the GMail app anyway, I think thats a minor issue to get this working correctly.

Related

Is it Okay to launch web URLs in UIWebView in iosApp?

I am not sure if this is grounds of app rejection or not:
In my app I receive JSON data from webserver and it has html content like
"[html] a href www.mycompany/view/regulations.html"... click for regulations...[/html]"
Is it okay to show the contents of the url above when clicking on "Click for regulations" link, or will this be rejected because I am under the impression that all html has to be carried locally?
That shouldn't be a problem. We have an app were our TOS is loaded from an (online) URL. What they usually don't like if your code loads from an external source.

File upload not working if the form link on Gmail is accessed on IE 9

My application sends email to users with a link to the application page where the user can upload a file for a business requirement. If the email is sent to a gmail id and when the user open the email in IE9 and clicks on the link, it navigates to the application page and when he tries to upload the file, it fails. There are no error messages shown on IE9 developer console.
The upload works fine in all browsers other than IE9.
If the user opens the link by right click -> Open in New tab, then the upload works fine
If the User clicks on the link directly, which by default Gmail will open in new tab on IE9, the upload fails.
I verified the URLs in either cases and there are no differences. I tried playing around with target attribute for the link (new, blank etc) and nothing helps.
Copy pasting the link in a new tabs works. But not clicking on the link
This is a IE9 issue - apparently you can work around it by setting IE9 in IE8 mode in Gmail (nice huh!)
Anyway there's a good write up here (and link to a demo project showing the issue):
https://github.com/blueimp/jQuery-File-Upload/issues/457
IE9 (and possibly other IE versions) doesn't allow submitting a HTML form programmatically (neither via form.submit() nor via button.click()), if the containing document has been opened via a Gmail link.

Open iPhone App from an Email Link

I've working on a program where an email is sent to a user, and a link to open the iPhone app is embedded in the email. The problem is that when the user clicks the link to open the app, mail has stripped out the colon, so the link no longer works!
The link being created basically looks like this:
#"<BR><BR><BR>Open App"
But the link, when clicked in the email, opens this in the browser instead:
myApp//
with no colon, so the app doesn't launch and the browser says it can't find the page.
Any ideas how to fix this? Thanks!
It just should be:
#"<BR><BR><BR>Open App"
As a workaround for custom urls being blocked by gmail, what you could do is set up something like http://myapp.mydomain.com/ up do redirect to myapp://... That way it'll look like a normal domain but open your app. On the plus you will be able to see how many people click your link, though on the down side it'll pop via Safari first.
Add 'http:' to all your images and urls, iphones dont recognize links w/o that. also use single quotes for them(').eg.
<a href='http://xyz.com'></a><img src='http://xyz.com/pqr/abc.jpg'></img>

Custom URL scheme embedded in an SMS on iPhone

Has anyone been able to successfully embed a custom url scheme in an SMS (for example someApp://), such that the iPhone upon receiving the SMS creates a clickable link to launch an app?
There are various questions similar to this out here, however, I have not seen a working solution.
Thanks
In general a custom URL scheme is the way to solve this problem. However, this is complicated by the fact that in iOS 5 (and up through iOS 5.1.1 based on my recent testing), Apple introduced a bug into their Messages app so that custom URLs received via SMS are not recognized as links.
See Custom URL scheme not recognized as link in SMS app(only in iphone 4 iOS 5.0)
You have to create URL scheme which starts with http, https or www.
but http:// and https:// will not work in URL scheme, so If you want create a click able link, you have to set your URL scheme with www.
For eg. www.myapp then the link which can open your app will be www.myapp:// but in this case only www.myapp will be click able and :// will not be click able.
For this use this format for URL scheme
www.<characters1>.<characters2>
www.my.app //example
Now use this format to open your app with click able URL:-
www.<characters1>.<characters2>://<anyThingYouWantToAppend>
www.my.app://open //example
www..:// is enough to open your app, but we are appending anyThingYouWantToAppend to create click able URL.
In my case on iOS 6, the link is not blue if sent from a custom sender ie text instead of a number. As soon as we started using a shortnumber as sender instead of a custom name, it was recognized as a link.
Assuming you have defined a custom url scheme as someApp:// you create a link in an SMS as follows:
"someApp://Myurl"

Error when using mailto: link in Mobile Safari in app-capable mode

I've got a form in a web page with an action that is "mailto:email" (where email is a real email address). When I load this page in Mobile Safari in regular mode (ie, not launched from home screen with app-capable mode), this works fine - after I submit the form, the email app comes up. However, when I'm in app-capable mode and have launched from the home screen (so, no Safari chrome), and submit the form I get the error "URL can't be shown". However, a regular mailto: link (ie, not in a form) does work when in app-capable mode.
Has anyone else noticed this? Any workarounds? Are forms disallowed in app-capable mode?
Thanks,
Elisabeth
This accurately describes the issue. There is nothing wrong with the mailto link, the mailto link fails to load. Often the webapp crashes.
The funny thing is that tel: link for telephone numbers work fine.
window.location.replace does in-fact work. Thanks!
Here is the jQuery to fix this automatically...
$('a[href^=mailto]').click(function (event) {
event.preventDefault();
window.location.replace = $(this).attr('href');
return false;
});
I think I've figured this out. I noticed when in app-capable mode, any http link will take you out of the app and launch a separate mobile safari window, take you to the page and show the Safari chrome. Makes sense (typically one wouldn't link to anything from an "all in one" app-capable web app. I noticed this because I implemented a 4 page app with my own "tab bar" at the bottom and was linking amongst the .html files with plain http links in the a element. When I replace this with a javascript function to load the pages using document.location.replace this doesn't happen.
So, on the form - I think what must be happening is that because I'm using a scheme (in this case, mailto:) somehow the browser is needed in "regular mode" to interpret the scheme and do the right thing by launching the email app and this clearly doesn't work when submitting a form. I haven't yet found anything in the Apple documentation specifically about this, so if anyone knows the technical details, please do post!
UPDATE: I did find that I can access a server side script using a form in web-app mode, so I'm still curious about the mailto: issue, if anyone has an answer.
Thanks,
Elisabeth
I am having the exact same issue with mailto links not working in the web capable mode. I just got done submitting a bug report to Apple. Let's see what happens, meanwhile I found another dev. platform for web apps that works in web capable mode and mailto links work, but it is funny how it works in this even--it is not as fluid as it is in Safari. Because even in this new web dev tool that I found, it closes your app and launches mail client, which is lame. In Safari it just slides in a mail window that slides back out if you hit cancel or send--it doesn't actually close your app.
Here is a workaround that does not depend on JQuery:
aTmp = document.createElement("a");
aTmp.href="mailto:example#example.com?subject=Test&body=Hello.";
aTmp.click();
Update: To run this code from a bookmarklet you have to wait about 1000 ms before the bookmarks bezel is closed and the browser is ready to respond. I realized this by wrapping the code in a setTimeout function.