在safari ios中打开保存在应用程序中的.mobileconfig文件

Red*_*Mak 7 iphone configuration install file ios

我正在尝试在safari中打开一个移动配置文件(mobileconfig)来安装它,但没有任何效果.我使用URL方案:

NSURL *finalURL = [NSURL URLWithString:[NSString stringWithFormat:@"myAppURLScheme://%@",fileName]];
BOOL canOpen = [[UIApplication sharedApplication] openURL:finalURL];
   if (canOpen) NSLog(@"can open");
   else NSLog(@"can't open");
Run Code Online (Sandbox Code Playgroud)

日志 - > can open

我尝试将所有路径(文件在Documents文件夹中)设置为文件而不是fileName,没有.我该怎么做.?

Edit1:这个应用程序也这样做(打开safari来安装配置)

EDIT2:我认为我必须寻找到发送文件(任何)Safari浏览器的方式,Safari就会知道该怎么做.

mal*_*ois 13

  1. 授权后台任务

.h文件:

UIBackgroundTaskIdentifier bgTask;
Run Code Online (Sandbox Code Playgroud)

.m文件:applicationDidEnterBackground添加新的后台任务:

bgTask = [application beginBackgroundTaskWithExpirationHandler: ^{
        dispatch_async(dispatch_get_main_queue(), ^{
            [application endBackgroundTask:self->bgTask];
            self->bgTask = UIBackgroundTaskInvalid;
        });
    }];
Run Code Online (Sandbox Code Playgroud)
  1. CocoaHTTPServer添加到您的项目中

  2. 运行服务器并打开.mobileconfig文件:

        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"]];
        }
    
    Run Code Online (Sandbox Code Playgroud)