Unable to open mobileconfig file in Safari ios devices

馋奶兔 提交于 2020-01-25 10:35:29

问题


I am making an app where it downloads mobileconfig from my server to my ios app. And I've created a server running background and used openUrl to open it in the safari so user can install the profile. But it only works in the simulator but not on my device.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://localhost:12345/file.mobileconfig"]];

where file.mobileconfig is downloaded in the root(localhost).

A.I ve implemented this solution: Open .mobileconfig file saved in application in safari ios but it works fine on the simulator but it doesn't fetch the files when I run it in the device.

B. I ve made a directory in the app as root(localhost folder). And Downloaded files are saved in the localhost.


Resolved

I was trying to fetch the data from app sandbox i.e xyz.app/Web/file which is not possible because of sandboxing.

step 1: Check for file existence: How to check if a file exists in Documents folder?

In my code I made "Web" as root and download folder when I checked for download files existences it didn't exist.

Step 2:I have made Documents as root and files are downloaded to the Documents which is publicly accessible.

Step 3: I checked on my devices it was working.


回答1:


That's because localhost inside the device is the device itself. You have to replace localhost with the LAN ip address of your computer (and it's not 127.0.0.1).



来源:https://stackoverflow.com/questions/28926846/unable-to-open-mobileconfig-file-in-safari-ios-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!