简体   繁体   English

无法在Safari iOS设备中打开mobileconfig文件

[英]Unable to open mobileconfig file in Safari ios devices

I am making an app where it downloads mobileconfig from my server to my ios app. 我正在制作一个应用程序,它将mobileconfig从服务器下载到ios应用程序。 And I've created a server running background and used openUrl to open it in the safari so user can install the profile. 我创建了一个运行后台的服务器,并使用openUrl在Safari中打开它,以便用户可以安装配置文件。 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). 在root(localhost)中下载file.mobileconfig的位置。

AI 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. 人工智能实现了此解决方案: 在safari ios中打开保存在应用程序中的.mobileconfig文件,但在模拟器上可以正常工作,但是当我在设备中运行该文件时无法获取文件。

B. I ve made a directory in the app as root(localhost folder). B.我已经在应用程序中以根目录(localhost文件夹)建立了目录。 And Downloaded files are saved in the localhost. 并且下载的文件保存在本地主机中。


Resolved 解决

I was trying to fetch the data from app sandbox ie xyz.app/Web/file which is not possible because of sandboxing. 我试图从应用程序沙箱中获取数据,即xyz.app/Web/file,这是由于沙箱操作而无法实现的。

step 1: Check for file existence: How to check if a file exists in Documents folder? 步骤1:检查文件是否存在: 如何检查Documents文件夹中是否存在文件?

In my code I made "Web" as root and download folder when I checked for download files existences it didn't exist. 在我的代码中,当我检查下载文件是否存在时,将“ Web”作为根目录和下载文件夹。

Step 2:I have made Documents as root and files are downloaded to the Documents which is publicly accessible. 步骤2:我已将文档作为根目录,并将文件下载到可公开访问的文档中。

Step 3: I checked on my devices it was working. 步骤3:我检查了装置是否运作正常。

That's because localhost inside the device is the device itself. 这是因为设备内部的localhost是设备本身。 You have to replace localhost with the LAN ip address of your computer (and it's not 127.0.0.1 ). 您必须将localhost替换为计算机的LAN ip地址(而不是127.0.0.1 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM