Open .mobileconfig file saved in an application in Safari ios

I am trying to open the configuration file for mobile devices (mobileconfig) in safari to install it, but nothing works. I use the 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'm trying to set the entire path (the file is in the Documents folder) instead of the fileName file, nothing. How can I do it.

Edit1 : this application does the same (open safari to set configuration)

Edit2 . I think I need to look for a way to send the file (any) in safari, and safari will know what to do with it.

+7
source share
4 answers
  • Authorize 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

  • Start 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"]]; } 
+13
source

The mobile configuration file is in your sandbox . Safari does not have access to it. The return value [UIApplication openURL] indicates only whether there was an application that understood the URL scheme . It seems to me that you are sending this URL to yourself, assuming that you have added myAppURLScheme as the uri handler to the info.plist file.

+3
source

I think you can use the data URI to encode and run mobileconfig. (I donโ€™t have an iOS device here, so I canโ€™t check right now _

You can use http://dopiaza.org/tools/datauri/index.php to encode your profile (do not forget to add the mime type: application / x-apple-aspen- config)

Then you can open:

 [[UIApplication sharedApplication] openURL:dataURLGenerated]; 
0
source

completely unlucky, but I still post this if someone else can use this information. I tried to open the line using data: url, which is supported by Mobile Safari, but not openURL: - unfortunately.

 NSString *urlHeader = @"data:application/x-apple-aspen-config;charset=utf-8,"; NSString *mobileConf = @"<?xmlversion=\"1.0\"encoding=\"UTF-8\"standalone=\"yes\"?>" "<!DOCTYPEplistPUBLIC\"-//Apple//DTDPLIST1.0//EN\"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" "<plistversion=\"1.0\"><dict><key>PayloadUUID</key><string>A0670934-C558-42E1-9E80-9B8E079E9AB2</string><key>PayloadDisplayName</key><string>EnableTethering</string><key>PayloadDescription</key><string>EnablesTethering</string><key>PayloadOrganization</key><string>de.iphone-notes</string><key>PayloadVersion</key><integer>1</integer><key>PayloadIdentifier</key><string>de.iphone-notes.etisalat</string><key>PayloadType</key><string>Configuration</string><key>PayloadContent</key><array><dict><key>PayloadUUID</key><string>C1A41907-0CD9-4DC9-BAF1-A04A73B7E296</string><key>PayloadDisplayName</key><string>AdvancedSettings</string><key>PayloadDescription</key><string>ProvidescustomizationofcarrierAccessPointName.</string><key>PayloadOrganization</key><string>de.sendowski</string><key>PayloadVersion</key><integer>1</integer><key>PayloadIdentifier</key><string>de.iphone-notes.etisalat.apn</string><key>PayloadContent</key><array><dict><key>DefaultsDomainName</key><string>com.apple.managedCarrier</string><key>DefaultsData</key><dict><key>apns</key><array><dict><key>apn</key><string>Etisalat.ae</string><key>username</key><string></string><key>password</key><string></string><key>type-mask</key><integer>-2</integer></dict></array></dict></dict></array><key>PayloadType</key><string>com.apple.apn.managed</string></dict></array></dict></plist>"; mobileConf = [mobileConf stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; NSURL *finalURL = [NSURL URLWithString:[urlHeader stringByAppendingString:mobileConf]]; BOOL canOpen = [[UIApplication sharedApplication] openURL:finalURL]; if (canOpen) NSLog(@"can open"); else NSLog(@"can't open"); 

For testing, you can add http:// to data: then it will at least open in Safari, and you can remove the prefix to try. Perhaps javascript injection will be used to remove the prefix; I dont know.

0
source

All Articles