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.
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.
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.
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.
.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"]];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With