打开保存在safari ios应用程序中的.mobileconfig文件 [英] Open .mobileconfig file saved in application in safari ios

查看:3026
本文介绍了打开保存在safari ios应用程序中的.mobileconfig文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在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 :我认为

解决方案


  1. 授权背景任务

.h文件:

  UIBackgroundTaskIdentifier bgTask; 

.m档案:
applicationDidEnterBackground 添加新的后台任务:

  bgTask = [application beginBackgroundTaskWithExpirationHandler:^ {
dispatch_async(dispatch_get_main_queue ^ {
[application endBackgroundTask:self-> bgTask];
self> bgTask = UIBackgroundTaskInvalid;
});
}];




  1. 添加

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

      RoutingHTTPServer * httpServer = [[RoutingHTTPServer alloc] init]; 
    [httpServer setType:@_ http._tcp。];
    [httpServer setPort:12345];
    [httpServer setDefaultHeader:@Content-Typevalue:@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 ]];
    }



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.

解决方案

  1. 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;
        });
    }];

  1. Add CocoaHTTPServer to your project

  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆