0
使用我的本机iOS应用程序设置MDM设备可让用户退出应用程序以加载Safari以启动MDM配置文件安装,然后返回到Safari。使用RoutingHTTPServer重定向iOS mdm配置文件?
我想要做的是返回到应用程序。
我知道这可以用RoutingHTTPServer完成,如记录here但我似乎无法得到一个MDM配置文件发布请求使用它。
任何帮助,非常感谢。
使用我的本机iOS应用程序设置MDM设备可让用户退出应用程序以加载Safari以启动MDM配置文件安装,然后返回到Safari。使用RoutingHTTPServer重定向iOS mdm配置文件?
我想要做的是返回到应用程序。
我知道这可以用RoutingHTTPServer完成,如记录here但我似乎无法得到一个MDM配置文件发布请求使用它。
任何帮助,非常感谢。
使用@xphod的另一篇文章中的代码,我得到它的工作如下,但它仍然不是很好。
基本上我需要Safari加载配置文件,用户安装它的配置文件,然后点击完成,当Safari重新打开它将引导用户回到应用程序。
我不认为它可以完成,也许最好的解决方法是托管一个网页做重定向回应用程序。
启动服务器和设置路由
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];
然后开始,
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://localhost:8000/start/"]];[/code]
将加载的Safari与JS计时器
- (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>"];
}
第一定时器加载Safari中的配置文件,然后第二重新定向到应用
- (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://"];
}
}