打开保存在safari ios应用程序中的.mobileconfig文件 [英] Open .mobileconfig file saved in application in safari ios
问题描述
我试图在safari中打开一个移动配置文件(mobileconfig)来安装它,但没有什么工作。
我使用URL Scheme:
NSURL * finalURL = [NSURL URLWithString:[NSString stringWithFormat:@myAppURLScheme: /%@,文件名]];
BOOL canOpen = [[UIApplication sharedApplication] openURL:finalURL];
if(canOpen)NSLog(@can open);
else NSLog(@can not open);
log - > 可以打开
p>
我尝试设置所有的路径(文件在文档
文件夹)而不是fileName, 。
我怎么能做到。 ?
Edit1 :此应用程序执行相同操作(打开safari安装配置)
Edit2 :我认为
- 授权背景任务
.h文件:
UIBackgroundTaskIdentifier bgTask;
.m档案:
在 applicationDidEnterBackground
添加新的后台任务:
bgTask = [application beginBackgroundTaskWithExpirationHandler:^ {
dispatch_async(dispatch_get_main_queue ^ {
[application endBackgroundTask:self-> bgTask];
self> bgTask = UIBackgroundTaskInvalid;
});
}];
I'm trying to open a mobile configuration file (mobileconfig) in safari to install it but nothing work. I use URL Scheme:
NSURL *finalURL = [NSURL URLWithString:[NSString stringWithFormat:@"myAppURLScheme://%@",fileName]];
BOOL canOpen = [[UIApplication sharedApplication] openURL:finalURL];
if (canOpen) NSLog(@"can open");
else NSLog(@"can't open");
log --> can open
and i try to set all the path(the file is in the Documents
folder) to the file instead fileName, nothing.
how can I do it. ?
Edit1: this application do the same(open safari to install configuration)
Edit2: I think that i have to search the way to send file(any) to safari, and safari will know what to do with it.
- Authorize a background task
.h file :
UIBackgroundTaskIdentifier bgTask;
.m file :
In applicationDidEnterBackground
add a new background task :
bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{
dispatch_async(dispatch_get_main_queue(), ^{
[application endBackgroundTask:self->bgTask];
self->bgTask = UIBackgroundTaskInvalid;
});
}];
Add CocoaHTTPServer to your project
Run the server and open the .mobileconfig file :
RoutingHTTPServer *httpServer = [[RoutingHTTPServer alloc] init]; [httpServer setType:@"_http._tcp."]; [httpServer setPort:12345]; [httpServer setDefaultHeader:@"Content-Type" value:@"application/x-apple-aspen-config"]; [httpServer setDocumentRoot:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]]; if([httpServer start:nil]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://localhost:12345/myprofile.mobileconfig"]]; }
这篇关于打开保存在safari ios应用程序中的.mobileconfig文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!