Using the code in the other post from @xaphod, I got it working as below but it's still not very good.
Basically I need Safari to load the profile, the user installs it the profile then clicks Done and when Safari re-opens it will direct the user back to the app.
I don't think it can be done, maybe the best workaround is hosting a webpage to do the redirection back to the app.
start server and setup routes
self.firstTime = true;
self.httpServer = [[RoutingHTTPServer alloc] init];
[self.httpServer setPort:8000];
[self.httpServer handleMethod:@"GET" withPath:@"/start" target:self selector:@selector(handleMobileconfigRootRequest:withResponse:)];
[self.httpServer handleMethod:@"GET" withPath:@"/load" target:self selector:@selector(handleMobileconfigLoadRequest:withResponse:)];
[self.httpServer start:NULL];
then to begin,
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://localhost:8000/start/"]];[/code]
which will load Safari with a JS timer
- (void)handleMobileconfigRootRequest:(RouteRequest *)request withResponse:(RouteResponse *)response
{
[response respondWithString:@"<HTML><HEAD><title>Profile Install</title>\
</HEAD><script> \
function load() { window.location.href='http://localhost:8000/load/';} \
var int=self.setTimeout(function(){load()},600); \
</script><BODY></BODY></HTML>"];
}
first timer loads the profile in Safari, then second re-direct to the app
- (void)handleMobileconfigLoadRequest:(RouteRequest *)request withResponse:(RouteResponse *)response
{
if (self.firstTime)
{
self.firstTime = FALSE;
NSData *mobileConfigFile = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://mobileconfigfileUrl"]];
[response setHeader:@"Content-Type" value:@"application/x-apple-aspen-config"];
[response respondWithData:mobileConfigFile];
}
else
{
[response setStatusCode:302];
[response setHeader:@"Location" value:@"CustomAppUrl://"];
}
}