What do I mean is that I want to use the app to create a shortcut with icon on the desktop which will allow user to speed access some functions of this app.
How could I do that, any suggestions? Or anyone have experience with this.
An example: FaceDial
I spent a good while trying to implement this functionality into an app recently and wanted to put out some of the resources I found on the subject to save someone else a major headache. This is becoming an increasingly popular feature and is used in major apps like Workflow and Facebook's Groups app. Given that Workflow is now an Apple app, it doesn't look like Apple has any issues with using this technique either. The answer provided by @jin is essentially correct. The process looks something like this:
Your webserver will need to display a page which returns another page in an base64 encoded format so that the user can use the shortcut after the webserver stops running (obviously you can't leave the embedded server running 24/7). The encode page will need to detect if the page was launched in standalone mode. If it was, then it should take you to your app, otherwise it should present you with a page where the user can save the page to the homescreen. Here's a sample of how my html looked for the service:
<!DOCTYPE html>
<html>
<div id="html">
<!DOCTYPE html>
<html>
<head>
<title>Add to Homescreen</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;" name="viewport"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="SHORTCUT NAME HERE" name="apple-mobile-web-app-title"/>
<link rel="icon" type="image/png" href="data:image/png;base64, ICON IMAGE DATA"/>
<link rel="apple-touch-icon" href="data:image/png;base64, ICON IMAGE DATA"/>
<link rel="apple-touch-startup-image" href="data:image/png;base64, ICON IMAGE DATA"/>
</head>
<body>
<a id="redirectURL" href="YOUR CUSTOM URL" name = "redirectURL"></a>
<script>
if (window.navigator.standalone) {
var e = document.getElementById('redirectURL');
var ev = document.createEvent('MouseEvents');
ev.initEvent('click', true, true);
e.dispatchEvent(ev);
window.close();
} else {
document.write("<center><h1>Valet</h1><img id=\"imageIcon\" src=\"data:image/png;base64, IMAGE ICON DATA\"></img><h2> Add this page to your homescreen </h2></center>")
}
</script>
</body>
</html>
</div>
<script type="text/javascript">
var html = document.getElementById("html").innerHTML;
html = html.replace(/\s{2,}/g, '')
.replace(/%/g, '%25')
.replace(/&/g, '%26')
.replace(/#/g, '%23')
.replace(/"/g, '%22')
.replace(/'/g, '%27');
var dataURI = 'data:text/html;charset=UTF-8,' + html;
window.location.href = dataURI
</script>
</html>
Here's a list of resources on the topic that helped me out (Sorry, I don't have enough reputation to include more than 2 links... so you'll have to copy pasta these):
https://gist.github.com/FokkeZB/5899387
https://stackoverflow.com/questions/28042152/link-to-safari-add-to-home-screen-from-inside-app
http://cubiq.org/add-to-home-screen
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
https://developer.apple.com/library/content/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html
https://stackoverflow.com/questions/9238890/convert-html-to-datatext-html-link-using-javascript
Let me know if anyone has any questions!
You can not add icons to the 'desktop' (Springboard) other than your application's. What this app is doing is displaying a replica of the iPhone 'desktop' within their app.
UPDATE: The link now points to an app which does this and it seems it is somewhat possible although rather hack in my opinion.
This is how I believe the application works (it is similar to answer below but in more detail).
You could implement something similar (although I wouldnt suggest it). These are the steps to follow:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
Note: If your application is deleted, the webclips will no longer work and will confuse the user. Apple may also reject your app.
I guess the application works as follows,
1) It just creating a html for each contact
2) It using the safari functionality "Add to home screen"
Found an excellent answer for simulating the safari functionality,
I created an link from Safari using the "Add To Home Screen" button. It created a directory called 54C86B09482D4560BAB46091CC75825A.webclip inside of /private/var/mobile/Library/WebClips/. That directory contains two files, icon.png and Info.plist. icon.png is simply the icon that gets shown when looking at the apps screen. The contents of Info.plist are where the real information is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ClassicMode</key>
<false/>
<key>FullScreen</key>
<false/>
<key>IconIsPrecomposed</key>
<false/>
<key>IconIsScreenShotBased</key>
<true/>
<key>Scale</key>
<real>0.32653060555458069</real>
<key>ScrollPoint</key>
<dict>
<key>x</key>
<real>0.0</real>
<key>y</key>
<real>-183</real>
</dict>
<key>Title</key>
<string>The Daily WTF</string>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleGray</string>
<key>URL</key>
<string>http://thedailywtf.com/</string>
</dict>
</plist>
So, to test this out I created a new folder called C28C8FDC2F184AAD84F77B511442548F.webclip and copied the Info.plist file over from the other directory, edited the url to http://google.com. I then re-sprung the phone and it showed up just like any other webclip. The folder name is simply a hex encoded GUID, I used http://www.somacon.com/p113.php and just selected what was after 0x for this simple test
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