I am using this to install mobileconfig file.
https://github.com/mattstevens/RoutingHTTPServer
Installing a configuration profile on iPhone - programmatically
In app delegate, I write this. It is from app, I will install mobileconfig file and it will go to safari. After that, it will go to setting and install. Then, it will go back to safari and from there, it will go back to app. But, if I open safari, it always route to my application and it doesn't stop. I need to do that only one time. How shall I do?
httpServer = [[RoutingHTTPServer alloc] init];
[httpServer setPort:8000]; // TODO: make sure this port isn't already in use
_firstTime = TRUE;
[httpServer handleMethod:@"GET" withPath:@"/start" target:self selector:@selector(handleMobileconfigRootRequest:withResponse:)];
[httpServer handleMethod:@"GET" withPath:@"/load" target:self selector:@selector(handleMobileconfigLoadRequest:withResponse:)];
NSMutableString* path = [NSMutableString stringWithString:[[NSBundle mainBundle] bundlePath]];
[path appendString:@"/test.mobileconfig"];
_mobileconfigData = [NSData dataWithContentsOfFile:path];
[httpServer start:NULL];
- (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.setInterval(function(){load()},400); \
</script><BODY></BODY></HTML>"];
}
- (void)handleMobileconfigLoadRequest:(RouteRequest *)request withResponse:(RouteResponse *)response {
if( _firstTime )
{
_firstTime = FALSE;
[response setHeader:@"Content-Type" value:@"application/x-apple-aspen-config"];
[response respondWithData:_mobileconfigData];
}
else
{
[response setStatusCode:302]; // or 301
[response setHeader:@"Location" value:@"Chan://"];
}
}