0

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.

Community
  • 1
  • 1
elviric
  • 1
  • 2

1 Answers1

0

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).

Eimantas
  • 48,927
  • 17
  • 132
  • 168
  • You just ignored his answer... You can't open the file on the device because it is not located on localhost. You need to find the ip of your computer on the homenetwork (protip: ifconfig in terminal). – Kristian Flatheim Jensen Mar 08 '15 at 16:16
  • @KristianFlatheimJensen I understand the scenario sending files over two connected socket in that situation we need to specify ip address of the devices. But my app doesn't communicate with other devices. Hence i specifying localhost is just fine. Thank you for your suggestions. – elviric Mar 08 '15 at 20:58