iOS blocks insecure requests
Native SDK binaries might attempt to access ad exchange servers via "insecure" HTTP (rather than HTTPS), which can fail due to iOS feature -- see Preventing Insecure Network Connections.
To allow such communication in your app, Info.plist
should be modified.
For more info see:
Here is a modified script that can be put inside Editor
folder to automate this task.
using UnityEditor;
using UnityEditor.Build;
using System.IO;
using UnityEditor.Build.Reporting;
using UnityEditor.iOS.Xcode;
// adds an ATS exception domain to the Info.plist
public class InfoPlistUpdater : IPostprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
public void OnPostprocessBuild(BuildReport report)
{
BuildTarget buildTarget = report.summary.platform;
string pathToBuiltProject = report.summary.outputPath;
if (buildTarget == BuildTarget.iOS)
{
// Get plist
string plistPath = pathToBuiltProject + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict allowsDict = plist.root.CreateDict("NSAppTransportSecurity");
allowsDict.SetBoolean("NSAllowsArbitraryLoads", true);
PlistElementDict exceptionsDict = allowsDict.CreateDict("NSExceptionDomains");
PlistElementDict domainDict = exceptionsDict.CreateDict("mobilesdk.io");
domainDict.SetBoolean("NSExceptionAllowsInsecureHTTPLoads", true);
domainDict.SetBoolean("NSIncludesSubdomains", true);
// Write to file
File.WriteAllText(plistPath, plist.WriteToString());
}
}
}