A method for making HTTP requests on Unity iOS?
I got threading to work on iOS- I believe it was crashing due to ghost threads or something. Restarting the device seems to have fixed the crashing so I'll just use WebRequest.HttpWebRequest with threads.
unity ios using https unable to make rest callout
I got it figured out. The issue was the url contained a % sign and ios apparently cant handle that.
UnityWebRequest not working in iOS
Found a solution. It turns out I had to specify in the Info.plist file that I want to allow "insecure" http connections for the iOS app.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>just-an-example.com</key>
<string></string>
</dict>
</dict>
Unity IOS app can't use UnityWebRequest to call self signed certificate HTTPS
A similar question has been asked here. Looks like you have to specify in the Info.plist file that you want to allow "insecure" http connections for the iOS app.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>just-an-example.com</key>
<string></string>
</dict>
</dict>
Unity 3D Puts/Deletes http methods
WebClient
and WebRequest
are both available in Unity and looks like it will only work with Pro Unity version just like any other API from the System.Net
namespace. I don't know if this restriction has changed in Unity 5. They support all those restful calls mentioned in your question.
Unity Added a new API called UnityWebRequest in version 5.2 with mobile platform support in 5.3. It was designed to replace WWW
and it supports all the restfull calls listed in your question. Below are example for each one. This is not a full example. You can find full examples in the link I provided above.
//Get
UnityWebRequest get = UnityWebRequest.Get("http://www.myserver.com/foo.txt");
//Post
UnityWebRequest post = UnityWebRequest.Post("http://www.myserver.com/foo.txt","Hello");
//Put
byte[] myData = System.Text.Encoding.UTF8.GetBytes("This is some test data");
UnityWebRequest put = UnityWebRequest.Put("http://www.my-server.com/upload", myData);
//Delete
UnityWebRequest delete = UnityWebRequest.Delete("http://www.myserver.com/foo.txt");
You can see complete example for each one including posting with json here.
Related Topics
How to Add Js and CSS Files in ASP.NET Core
Simple iOS Bluetooth Data Transmission Using Unity
Python: Inflate and Deflate Implementations
Closing Excel Application Process in C# After Data Access
Why Aren't C# Static Class Extension Methods Supported
Get the Icon for a Given Extension
How to Cast String to Int. Error Msg: Input String Was Not in a Correct Format
How to Update the Value Stored in Dictionary in C#
How to Elegantly Check If a Number Is Within a Range
ASP.NET Core 2.0-2.2 Kestrel Not Serving Static Content
Executing R Script Programmatically
How to Pass Constructor Parameters to Unity's Resolve() Method
Standardoutput.Readtoend() Hangs
Read Fixed Width Record from Text File
Error on If Statement - Cannot Implicitly Convert Type to 'Bool'