I would like to send a configuration profile with my iPhone application and install it if necessary.
Remember, we are talking about a configuration profile, not a provisioning profile.
Firstly, such a task is possible. If you place a configuration profile on a web page and click on it from Safari, it will be installed. If you send an email profile and click on the attachment, it will also be installed. “Installed” in this case means “The installation user interface is initialized” - but I could not even get to this.
So, I worked on the theory that initiating a profile installation involves navigating to it as a URL. I added a profile to my application package.
A) First I tried [sharedApp openURL] with file: // URL in my package. There is no such luck - nothing happens.
B) Then I added an HTML page to my package that has a profile link and uploaded it to UIWebView. Clicking on a link does nothing. However, loading an identical page from a web server in Safari works fine - the link is clickable, the profile is set. I provided a UIWebViewDelegate, responding YES to every navigation request - no difference.
C) Then I tried to load the same web page from my package into Safari (using [sharedApp openURL] - nothing happens. I think Safari cannot see the files inside my application package.
D) Loading the page and profile on the web server is feasible, but the pain is at the organizational level, not to mention an additional source of failures (what if there is no 3G coverage?).
So my big question is: ** how to programmatically set a profile?
And small questions: what can a link do without clicks in UIWebView? Can I upload a file: // URL from my package in Safari? If not, is there a local location on the iPhone where I can place the files and Safari can find them?
EDIT on B): the problem is that we are attached to the profile. I renamed it from .mobileconfig to .xml (because it is really XML), changed the link. And the link worked in my UIWebView. Renamed it back - same thing. UIWebView seems to be reluctant to run all applications - since setting a profile closes the application. I tried to say that everything was fine - using the UIWebViewDelegate - but that did not convince. This behavior is for mailto: URLs in the UIWebView interface.
For mailto URLs: the general way is to translate them into [openURL] calls, but this doesn’t quite work for my case, see scenario A.
For itms: URL, however UIWebView works as expected ...
EDIT2: tried to submit data url to Safari via [openURL] - does not work, see here: iPhone Open DATA: Url In Safari
EDIT3: Found a lot of information on how Safari does not support files: // URL. UIWebView, however, really like it. In addition, Safari on the simulator opens them just fine. The last bit is the most frustrating.
EDIT4: I did not find a solution. Instead, I put together a two-bit web interface where users can order a profile sent to them by email.