title: Installing a configuration profile on iPhone - programmatically
body: <p>I would like to ship a configuration profile with my iPhone application, and install it if needed. </p>
  
  <p>Mind you, we're talking about a configuration profile, not a provisioning profile.</p>
  
  <p>First off, such a task is possible. If you place a config profile on a Web page and click on it from Safari, it will get installed. If you e-mail a profile and click the attachment, it will install as well. "Installed" in this case means "The installation UI is invoked" - but I could not even get that far.</p>
  
  <p>So I was working under the theory that initiating a profile installation involves navigating to it as a URL. I added the profile to my app bundle.</p>
  
  <p><strong>A)</strong> First, I tried [sharedApp openURL] with the file:// URL into my bundle. No such luck - nothing happens.</p>
  
  <p><strong>B)</strong> I then added an HTML page to my bundle that has a link to the profile, and loaded it into a UIWebView. Clicking on the link does nothing. Loading an identical page from a Web server in Safari, however, works fine - the link is clickable, the profile installs. I provided a UIWebViewDelegate, answering YES to every navigation request - no difference.</p>
  
  <p><strong>C)</strong> Then I tried to load the same Web page from my bundle in Safari (using [sharedApp openURL] - nothing happens. I guess, Safari cannot see files inside my app bundle.</p>
  
  <p><strong>D)</strong> Uploading the page and the profile on a Web server is doable, but a pain on the organizational level, not to mention an extra source of failures (what if no 3G coverage? etc.).</p>
  
  <p><strong>So my big question is: **how do I install a profile programmatically?</strong></p>
  
  <p>And the little questions are: what can make a link non-clickable within a UIWebView? Is it possible to load a file:// URL from <em>my</em> bundle in Safari? If not, is there a local location on iPhone where I can place files and Safari can find them?</p>
  
  <p><strong>EDIT on B):</strong> the problem is somehow in the fact that we're linking to a profile. I renamed it from .mobileconfig to .xml ('cause it's really XML), altered the link. And the link worked in my UIWebView. Renamed it back - same stuff. It looks as if UIWebView is reluctant to do application-wide stuff - since installation of the profile closes the app. I tried telling it that it's OK - by means of UIWebViewDelegate - but that did not convince. Same behavior for mailto: URLs within UIWebView.</p>
  
  <p><strong>For mailto:</strong> URLs the common technique is to translate them into [openURL] calls, but that doesn't quite work for my case, see scenario A.</p>
  
  <p>For itms: URLs, however, UIWebView works as expected...</p>
  
  <p><strong>EDIT2:</strong> tried feeding a data URL to Safari via [openURL] - does not work, see here: <a href="https://stackoverflow.com/questions/641461/iphone-open-data-url-in-safari">iPhone Open DATA: Url In Safari</a></p>
  
  <p><strong>EDIT3:</strong> found a lot of info on how Safari does not support file:// URLs. UIWebView, however, very much does. Also, Safari on the simulator open them just fine. The latter bit is the most frustrating.</p>
  
  <hr>
  
  <p><strong>EDIT4:</strong> I never found a solution. Instead, I put together a two-bit Web interface where the users can order the profile e-mailed to them.</p>