Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open .mobileconfig file saved in application in safari ios

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.

like image 639
Red Mak Avatar asked Feb 12 '13 15:02

Red Mak


People also ask

How do I use .mobileconfig file on Iphone?

Your iOS or iPadOS device should recognize the file and go to Settings > General > Profiles for you. Tap Install to install the profile. A . mobileconfig file will be installed on your iOS or iPadOS device.

What is a mobile config file?

These files are helpful with setting up features like Wi-Fi networks or E-Mail accounts, and provide an easy way to distribute configuration information to multiple devices.

How do I create a Mobileconfig file?

Select Management > Mobile Config. Click Add and enter a name and description for the new mobile config file. Click Add to confirm the addition of the new file. Select the new configuration file from the left side of the page, and make sure it is enabled.


1 Answers

  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"]];
        }
    
like image 103
malinois Avatar answered Oct 05 '22 17:10

malinois