root/site/pages/iphone/tutorial.html
@
756
| Revision 756, 18.0 kB (checked in by nadya, 3 years ago) |
|---|
| Line | |
|---|---|
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> |
| 5 | <link rel="icon" href="/pages/images/favicon.ico" type="image"/> |
| 6 | <title>Telnic | Developing for iPhone</title> |
| 7 | <link rel="stylesheet" href="/pages/css/css.css" type="text/css"/> |
| 8 | <link rel="stylesheet" href="/pages/css/print.css" type="text/css"/> |
| 9 | <link rel="stylesheet" href="/pages/css/nav.css" type="text/css"/> |
| 10 | <script src="/pages/js/jquery.pack.js"> |
| 11 | </script> |
| 12 | <script src="/pages/js/jquery.js"> |
| 13 | </script> |
| 14 | <script src="/pages/js/swfobject.js"> |
| 15 | </script> |
| 16 | <script src="/pages/js/menu.js"> |
| 17 | </script> |
| 18 | <script src="/pages/js/utils.js"> |
| 19 | </script> |
| 20 | <meta name="author" value="Telnic Developer Community"/> |
| 21 | <meta name="email" value="general.AT.developer.DOT.telnic.DOT.org"/> |
| 22 | </head> |
| 23 | <body> |
| 24 | <!--PAGE HEADER--> |
| 25 | <div id="SiteContainer"> |
| 26 | <!--TELNIC LOGO--> |
| 27 | <div class="Header"> |
| 28 | <div> |
| 29 | <a href="/index.html"> |
| 30 | <img src="/pages/images/trans.gif" class="LogoBG" alt=""/> |
| 31 | </a> |
| 32 | </div> |
| 33 | <div class="DeveloperAreaTitle">Developer Area</div> |
| 34 | <div class="TopSubMenuBG"> |
| 35 | <a href="http://telnic.org" class="SubMenuLink">Go to main website</a> |
| 36 | </div> |
| 37 | </div> |
| 38 | <div class="SubMidleBG"> |
| 39 | <!--LEFT SIDE NAVIGATION--> |
| 40 | <div class="DevelopersLeft"> |
| 41 | <div id="navcol"> |
| 42 | <div class="CommunityLeftTitleBg"> |
| 43 | <a href="/" class="CommunityLeftTitleLink">Developers</a> |
| 44 | </div> |
| 45 | <ul class="menu level1"> |
| 46 | <li class="menu"> |
| 47 | <a href="/">Home</a> |
| 48 | </li> |
| 49 | <li class="menu"> |
| 50 | <a href="/pages/architecture.html">Architecture</a> |
| 51 | <ul class="sub level2"> |
| 52 | <li class="menu"> |
| 53 | <a href="/pages/general_landing.html">.tel Basics</a> |
| 54 | </li> |
| 55 | <li class="menu"> |
| 56 | <a href="/pages/record_types.html">DNS Records</a> |
| 57 | </li> |
| 58 | <li class="menu"> |
| 59 | <a href="/pages/security.html">Privacy</a> |
| 60 | </li> |
| 61 | <li class="menu"> |
| 62 | <a href="/pages/telhosting.html">TelHosting</a> |
| 63 | </li> |
| 64 | <li class="menu"> |
| 65 | <a href="/pages/openid.html">OpenID</a> |
| 66 | </li> |
| 67 | <li class="menu"> |
| 68 | <a href="/pages/oauth.html">OpenAuth</a> |
| 69 | </li> |
| 70 | </ul> |
| 71 | </li> |
| 72 | <li class="menu"> |
| 73 | <a href="/pages/ecosystem.html">Ecosystem</a> |
| 74 | <ul class="sub level2"> |
| 75 | <li class="menu"> |
| 76 | <a href="/pages/bizcards.html">.tel Names</a> |
| 77 | </li> |
| 78 | <li class="menu"> |
| 79 | <a href="/pages/solutions.html">.tel Solutions</a> |
| 80 | </li> |
| 81 | <li class="menu"> |
| 82 | <a href="/pages/services.html">.tel Services</a> |
| 83 | </li> |
| 84 | <li class="menu"> |
| 85 | <a href="/pages/search_engines.html">.tel Search Engines</a> |
| 86 | </li> |
| 87 | <li class="menu"> |
| 88 | <a href="/pages/directories.html">.tel Directories</a> |
| 89 | </li> |
| 90 | <li class="menu"> |
| 91 | <a href="/pages/seo.html">SEO</a> |
| 92 | </li> |
| 93 | </ul> |
| 94 | </li> |
| 95 | <li class="menu"> |
| 96 | <a href="/pages/downloads.html">Software</a> |
| 97 | <ul class="sub level2"> |
| 98 | <li class="menu"> |
| 99 | <a href="/pages/iphone/landing.html">iPhone</a> |
| 100 | </li> |
| 101 | <li class="menu"> |
| 102 | <a href="/pages/android/landing.html">Android</a> |
| 103 | </li> |
| 104 | <li class="menu"> |
| 105 | <a href="/pages/blackberry/landing.html">BlackBerry</a> |
| 106 | </li> |
| 107 | <li class="menu"> |
| 108 | <a href="/pages/winmobile/landing.html">Windows Mobile</a> |
| 109 | </li> |
| 110 | <li class="menu"> |
| 111 | <a href="/pages/winoutlook/landing.html">Outlook</a> |
| 112 | </li> |
| 113 | <li class="menu"> |
| 114 | <a href="/pages/more_apps.html">Softphone</a> |
| 115 | </li> |
| 116 | <li class="menu"> |
| 117 | <a href="/pages/webmaster.html">Webmaster Tools</a> |
| 118 | </li> |
| 119 | <li class="menu"> |
| 120 | <a href="/pages/th/landing.html">TelHosting Software</a> |
| 121 | </li> |
| 122 | </ul> |
| 123 | </li> |
| 124 | <li class="menu"> |
| 125 | <a href="/trac">Developers</a> |
| 126 | <ul class="sub level2"> |
| 127 | <li class="menu"> |
| 128 | <a href="/trac/register">Sign up</a> |
| 129 | </li> |
| 130 | <li class="menu"> |
| 131 | <a href="/trac/login">Log in</a> |
| 132 | </li> |
| 133 | <li class="menu"> |
| 134 | <a href="/trac/discussion">Forum</a> |
| 135 | </li> |
| 136 | <li class="menu"> |
| 137 | <a href="/trac/wiki/SourceCode">Source Code</a> |
| 138 | </li> |
| 139 | <li class="menu"> |
| 140 | <a href="/trac/wiki/BugTracker">Bug Tracker</a> |
| 141 | </li> |
| 142 | <li class="menu"> |
| 143 | <a href="/pages/tools.html">Tools</a> |
| 144 | </li> |
| 145 | <li class="menu"> |
| 146 | <a href="/trac/wiki/TracWiki">Wiki</a> |
| 147 | </li> |
| 148 | <li class="menu"> |
| 149 | <a href="/trac/wiki/RssFeed">RSS</a> |
| 150 | </li> |
| 151 | </ul> |
| 152 | </li> |
| 153 | <li class="menu"> |
| 154 | <a href="/pages/doc_index.html">Documentation</a> |
| 155 | </li> |
| 156 | <li class="menu"> |
| 157 | <a href="/pages/faq.html">FAQ</a> |
| 158 | </li> |
| 159 | </ul> |
| 160 | <div> |
| 161 | <img src="/pages/images/tel-community-bot.gif"/> |
| 162 | </div> |
| 163 | </div> |
| 164 | </div> |
| 165 | <!--MAIN BODY--> |
| 166 | <div class="CommunityMidle"> |
| 167 | <a name="How to develop a .tel Application for iPhone?"> |
| 168 | <h1>How to develop a .tel Application for iPhone?</h1> |
| 169 | </a> |
| 170 | <p> |
| 171 | This guide focuses on the flow of development of a .tel application using a ready-made iPhone application for .tel as an example. The document is targeted at developers wishing to get a quick start with .tel client code development, and relies on understanding of the key .tel principles, knowledge of Objective C, and the iPhone architecture.</p> |
| 172 | <p> Unlike the API references and the Developer's Manual, this document highlights the flow of the development. To give developers a kick start with mobile application development, the .tel community offers an iPhone SDK and the sample application that performs DNS lookups. These are downloadable under an open-source BSD-style license, and offer an excellent base to build upon. Section 2 below lists the full set of prerequisites required for iPhone application development. </p> |
| 173 | <p> The document covers only a small part of the available APIS, and is merely a sample, not a guideline. Other .tel applications can implement a totally different set of functions; for example, "My .tel" uses the AJAX API to allow managing contents of a .tel domain: add and remove contacts, keywords, text and location information. </p> |
| 174 | <p> The sample application and the .tel iPhone SDK mentioned in this document are for iPhone 2.0 and higher, and use SOAP to communicate with TelHosting Software.</p> |
| 175 | |
| 176 | <a name="Getting Ready"> |
| 177 | <h2>Getting Ready</h2> |
| 178 | </a> |
| 179 | |
| 180 | <p>Before you start with your first .tel iPhone application, you need to prepare the development environment. As a developer, you will need some knowledge of Objective C and some understanding of the iPhone architecture. <br/> |
| 181 | For the development environment, you need:</p> |
| 182 | <ul type="disc"> |
| 183 | <li>The full iPhone SDK that you can obtain at the official website, http://developer.apple.com/iphone/. Read the accompanying documentation for installation instructions. </li> |
| 184 | <li>The XCode environment of the version specified the iPhone SDK installation instructions.</li> |
| 185 | <li>The sample iPhone application from <a href="http://dev.telnic.org/downloads/iphone_1.1.zip">http://dev.telnic.org/downloads/iphone_1.1.zip</a> extracted to a local directory.</li> |
| 186 | </ul> |
| 187 | |
| 188 | |
| 189 | <a name="Importing the Project"> |
| 190 | <h2>Importing the Project</h2> |
| 191 | </a> |
| 192 | <p>To import the sample .tel application into your iPhone environment, double-click the <code>sampleTelApp.xcodeproj</code> file inside the sample .tel application directory. XCode should automatically launch and load the project.</p> |
| 193 | |
| 194 | |
| 195 | <a name="Application Architecture"> |
| 196 | <h2>Application Architecture</h2> |
| 197 | </a> |
| 198 | |
| 199 | <p>The sample .tel application described in this document performs DNS lookups of .tel domain names and displays returned results in a table. Each supported type of contact is associated with an external program that can be launched by selecting the contact. The application does not decrypt private records, so only publicly available content is displayed to the user.<br/> |
| 200 | The application is a minimalist user interface wrapper over the .tel SDK files. As such, it includes very little additional code. The only class with custom code (as opposed to Apple-provided bootstrapping skeleton) is <code>sampleTelAppViewController</code>.</p> |
| 201 | <p>The <code>sampleTelAppViewController</code> class is the controller for the main application view. It implements:</p> |
| 202 | <ul type="disc"> |
| 203 | <li>The basic view controller methods such as <code>init()</code> and <code>viewDidLoad()</code> |
| 204 | </li> |
| 205 | <li>Action calls for the main view</li> |
| 206 | <li>Data Source methods for the <code>tableView</code> that displays .tel info in the main view</li> |
| 207 | <li>Delegate methods for that same <code>tableView</code> |
| 208 | </li> |
| 209 | <li>Delegate methods for a <code>UIAlertView</code> that is triggered in case of a data connection error</li> |
| 210 | <li>URL connection delegate methods for testing the data connections</li> |
| 211 | </ul> |
| 212 | <p>The controller starts by initializing the network through a test web connection to Google. If that succeeds, it creates a new instance of the <code>DnsResolver</code> class and initializes 3 arrays that will hold the .tel DNS data:</p> |
| 213 | <ul> |
| 214 | <li> <code>naptrArray</code> holds the NAPTR records</li> |
| 215 | <li> <code>txtArray</code> holds the TXT records</li> |
| 216 | <li> <code>locArray</code> holds the LOC records (there should only be one LOC record per (sub)domain)</li> |
| 217 | </ul> |
| 218 | |
| 219 | <p>It also initializes the <code>headerText</code> string that will hold the header record, which is a TXT record without the ".tkw" keyword modifier string. That record is displayed at the top of the display table for the domain. Please see the isHeader property in the <code>RecordTxt</code> class of the .tel iPhone SDK for more information about the header text.</p> |
| 220 | <p>When the user requests the .tel data for a domain, the controller launches the method <code>lookupDomain:domain</code> to fill the data arrays. Control is then given back to the UI that shows the correct cells in the displayed <code>tableView</code>, using the table view cell NIB.</p> |
| 221 | |
| 222 | |
| 223 | <a name="Core Functions"> |
| 224 | <h2>Core Functions</h2> |
| 225 | </a> |
| 226 | |
| 227 | <p>The sample .tel application performs DNS lookups by using the iPhone SDK with the modified ldns library. The results are displayed in a table.<br/> |
| 228 | The main functions are:</p> |
| 229 | <dl> |
| 230 | <dt>(void)lookupDomain:(NSString *)domain</dt> |
| 231 | <dd> |
| 232 | <p>lookupDomain:domain is the main method to look up a domain and fill the data sources for the tableView to display. The method calls in turn from the .tel SDK the methods getNAPTRForTel, getTXTForTel and getLOCForTel, and fills the respective arrays naptrArray, txtArray (including headerText) and locArray.<br/> |
| 233 | Finally it asks the tableView to reload its data from those arrays.</p> |
| 234 | </dd> |
| 235 | <dt>(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</dt> |
| 236 | <dd> |
| 237 | <p>This data source method requests the proper cell to display. The work is pretty simple: determine in which section the cell is located (header, naptr, txt or loc), and grab the correct entry from headerText, naptrArray, txtArray or locArray.<br/> |
| 238 | The method also loads the correct NIB file to display the cell.</p> |
| 239 | </dd> |
| 240 | <dt>(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath</dt> |
| 241 | <dd> |
| 242 | <p>This method acts upon a selected row.<br/> |
| 243 | If it is a row with a terminal NAPTR, it asks the Operating System to launch that URL. That operation can fail if no application has registered that URL scheme on the user's phone.<br/> |
| 244 | If it is a non-terminal NAPTR, the application looks up the specified domain name.<br/> |
| 245 | Finally, if it is a LOC record, a properly formatted Google Maps URL is created and requested.</p> |
| 246 | </dd> |
| 247 | </dl> |
| 248 | |
| 249 | <a name="Testing Your Application"> |
| 250 | <h2>Testing Your Application</h2> |
| 251 | </a> |
| 252 | |
| 253 | <p>To test that the imported project works correctly, compile and test it.<br/> |
| 254 | It is easiest to test using the iPhone Simulator included into the SDK. If you wish to compile it for a device, ensure that you've correctly modified the Bundle identifier in the Info.plist file, and that you've included the correct code signing files. That part is out of the scope of this document, please refer to the Apple Developer website for more information.</p> |
| 255 | |
| 256 | <a name="Extending Functionality"> |
| 257 | <h2>Extending Functionality</h2> |
| 258 | </a> |
| 259 | <p>The main purpose of the sample .tel iPhone application is to demonstrate the basic .tel-related operations and implementation workflow. To create a full-scale application for iPhone devices, more functionality needs to be added, including the following:</p> |
| 260 | <h3>Private Record Handling</h3> |
| 261 | <p> In order to support private record handling, the following needs to be added to the application:</p> |
| 262 | <ul> |
| 263 | <li>A Preferences pane to input the user's Sponsoring Organization (SO) credentials, and a mechanism to securely store those credentials</li> |
| 264 | <li>A "cold boot" routine that retrieves the user's private key from the SO Friending system when the user first enters the OS credentials</li> |
| 265 | <li>Retrieval of the publisher's list from the SO system to check whether a queried domain contains private data for the querying user; if private data is available, a redirect operation to retrieve the encrypted records from the unique sub-domain </li> |
| 266 | <li> Decryption of retrieved encrypted data with the private key. |
| 267 | <br/> |
| 268 | In addition, when a private key is available, your application should automatically try to decrypt every RecordNaptr that has the isEncrypted property.</li> |
| 269 | </ul> |
| 270 | <h3>Better sub-domain navigation</h3> |
| 271 | |
| 272 | <p> |
| 273 | The application should use a <code>UINavigationController</code> on top of the <code>TableViewController</code> in order to properly navigate sub-domains, including going back up the navigation tree.<br/> |
| 274 | Given an existing <code>navigationController</code>, here's sample code for navigating a Non-Terminal NAPTR subdomain:</p> |
| 275 | <pre>[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];<br/> |
| 276 | UITableViewController *newNaptrController = [[UITableViewController alloc] initWithNibName:nil bundle:nil];<br/> |
| 277 | newNaptrController.title = subdomain;<br/> |
| 278 | [newNaptrController getNaptrsForTel:subdomain];<br/> |
| 279 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];<br/> |
| 280 | [tableView deselectRowAtIndexPath:indexPath animated:NO];<br/> |
| 281 | [[self navigationController] pushViewController:newNaptrController animated:YES];<br/> |
| 282 | [newNaptrController release];</pre> |
| 283 | <p>As you can see, .tel domain navigation is perfectly suited to the iPhone's navigation UI. Retrieving NAPTRs is extremely quick, and has just the necessary data to display on the iPhone navigation UI.</p> |
| 284 | |
| 285 | |
| 286 | </div> |
| 287 | <div class="clear"> </div> |
| 288 | </div> |
| 289 | <!--FOOTER SEPARATOR--> |
| 290 | <div> |
| 291 | <img src="/pages/images/Bot-image-bg.gif"/> |
| 292 | </div> |
| 293 | <div class="FooterBoxBG"> |
| 294 | <div> |
| 295 | <img src="/pages/images/top-image-bg.gif" alt="Telnic" title="Telnic"/> |
| 296 | </div> |
| 297 | <div class="FooterMidleBoxBG"> |
| 298 | <div class="FooterBoxLeftTelLogo"> |
| 299 | <div class="FooterTitleAboutUs">About Us</div> |
| 300 | <div class="FloatLeft"> |
| 301 | <a href="/aboutus.html"> |
| 302 | <img src="/pages/images/footer-telnic-logo.jpg" alt="About Telnic" title="Telnic"/> |
| 303 | </a> |
| 304 | </div> |
| 305 | <a href="/community-rss.html"> |
| 306 | <img src="/pages/images/twitter-icon-bot.jpg" alt="Twitter" border="0" class="BotNewIcon"/> |
| 307 | </a> |
| 308 | <a href="http://www.facebook.com/pages/tel-domain/23548413959" target="_blank"> |
| 309 | <img src="/pages/images/face-book-icon.jpg" alt="Face Book" border="0" class="BotNewIcon"/> |
| 310 | </a> |
| 311 | <a href="http://www.linkedin.com/groups?gid=770077" target="_blank"> |
| 312 | <img src="/pages/images/linkedin-icon.png" alt="LinkedIn" border="0" class="BotNewIcon"/> |
| 313 | </a> |
| 314 | <a href="/community-rss.html"> |
| 315 | <img src="/pages/images/rss-iocn-bot.jpg" alt="Rss" border="0" class="BotNewIcon"/> |
| 316 | </a> |
| 317 | </div> |
| 318 | <div class="FooterBoxLeftMofeLogo"> |
| 319 | <div class="FooterTitleCertifications">Awards</div> |
| 320 | <div class="FloatLeft"> |
| 321 | <a href="http://telnic.org/downloads/TelnicWinsUKITAwards.pdf" target="_blank"> |
| 322 | <img src="/pages/images/UKITawards.jpg" alt="World Technology Award 2009 NOMINEE" title="World Technology Award 2009 NOMINEE"/> |
| 323 | </a> |
| 324 | <a href="http://telnic.org/downloads/TelnicWinsInfoCommerceMofE.pdf" target="_blank"> |
| 325 | <img src="/pages/images/MofELogo.jpg" alt="Mofe" title="Mofe"/> |
| 326 | </a> |
| 327 | <a href="http://telnic.org/downloads/TelnicWinsSilverwareCeBIT.pdf" target="_blank"> |
| 328 | <img src="/pages/images/Seal_Argent_2010.jpg" alt="European Seal of E-excellence" title="Mofe"/> |
| 329 | </a> |
| 330 | </div> |
| 331 | </div> |
| 332 | <div class="FooterBoxRightBG"> |
| 333 | <div class="FooterTwoTitleBG">Search This Site</div> |
| 334 | <form action="http://www.google.com/search" method="get"> |
| 335 | <input value="telnic.org" name="sitesearch" type="hidden"/> |
| 336 | <input size="10" name="q" id="query" type="text"/> |
| 337 | <input name="Search" id="btnSubmit" value="Search" src="../images/bot-search-icon.jpg" class="ImageMidle" tabindex="3" type="submit"/> |
| 338 | </form> |
| 339 | </div> |
| 340 | <div class="FooterBoxMidleBG"> |
| 341 | <div class="FooterTitleBG">Partners</div> |
| 342 | <div class="PartnersImageBG"> |
| 343 | <a href="http://www.neustar.biz/" target="_blank"> |
| 344 | <img src="/pages/images/neustar.jpg" alt="Neustar" title="Neustar"/> |
| 345 | </a> |
| 346 | <a href="http://icann.org/" target="_blank"> |
| 347 | <img src="/pages/images/icann.jpg" alt="ICANN" title="ICANN"/> |
| 348 | </a> |
| 349 | <a href="http://www.fsb.org.uk/" target="_blank"> |
| 350 | <img src="/pages/images/fsb_logo.jpg" alt="FSB" title="FSB"/> |
| 351 | </a> |
| 352 | </div> |
| 353 | </div> |
| 354 | </div> |
| 355 | <div> |
| 356 | <img src="/pages/images/Bot-image-bg.gif"/> |
| 357 | </div> |
| 358 | </div> |
| 359 | <div class="BotMenuBG"> |
| 360 | <a href="http://telnic.org" class="BotMenuLink" target="_blank">Main site</a> | |
| 361 | <a href="http://telnic.org/whois.html" class="BotMenuLink" target="_blank">WHOIS</a> | |
| 362 | <a href="http://telnic.org/sell-landing.html" class="BotMenuLink" target="_blank">Sell .tel</a> | |
| 363 | <a href="http://telnic.org/faq.html" class="BotMenuLink" target="_blank">FAQ</a> | |
| 364 | <a href="http://archive.telnic.org" target="_blank" class="BotMenuLink">Archived Site</a> | |
| 365 | <a href="http://telnic.org/aboutus.html" class="BotMenuLink" target="_blank">About Telnic</a> | |
| 366 | <a href="http://telnic.org/contact.html" class="BotMenuLink" target="_blank">Contact Us</a> |
| 367 | </div> |
| 368 | <div class="CopyRight"> |
| 369 | <a href="/pages/legal.html" class="CopyRightLink"> Legal and Privacy</a> © 2009-2010 Telnic Limited.</div> |
| 370 | <script type="text/javascript"> |
| 371 | var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); |
| 372 | </script> |
| 373 | <script type="text/javascript"> |
| 374 | try { |
| 375 | var pageTracker = _gat._getTracker("UA-10317102-2"); |
| 376 | pageTracker._trackPageview(); |
| 377 | } catch(err) {} |
| 378 | </script> |
| 379 | </div> |
| 380 | </body> |
| 381 | </html> |
Note: See TracBrowser
for help on using the browser.








