iOS App : Porting Code to App

0 votes

So, I'm attempting to port the post action(not the format) of this code to an iOS app. 

center><br>
<br>
<br>
<form action="https://api.particle.io/v1/devices/your-device-ID-goes-here/led?access_token=your-access-token-goes-here" method="POST">
Tell your device what to do!<br>
<br>
<input type="radio" name="args" value="on">Turn the LED on.
<br>
<input type="radio" name="args" value="off">Turn the LED off.
<br>
<br>
<input type="submit" value="Do it!">
</form>
</center>
and now I'm stuck with this.
import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.


        let myUrl = NSURL(string: "https://api.particle.io/v1/devices/your-device-ID-goes-here/led?access_token=your-access-token-goes-here")
        let request = NSMutableURLRequest (URL:myUrl!)
        request.HTTPMethod = "POST"
}


Kindly help me out with how to proceed.

Thanks.

Jan 18, 2019 in IoT (Internet of Things) by Upasana
• 8,590 points
38 views

1 answer to this question.

0 votes

If you make a post, missing parameters ... it would have to see this.

let request = NSMutableURLRequest(URL: NSURL(string: "http://www.thisismylink.com/postName.php"))
request.HTTPMethod = "POST"
let postString = "id=13&name=Jack"
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in

if error != nil {
    println("error=\(error)")
    return
}

println("response = \(response)")

let responseString = NSString(data: data, encoding: NSUTF8StringEncoding)
println("responseString = \(responseString)")
}
task.resume()

Kindly see this framework on git for more detail

https://github.com/daltoniam/SwiftHTTP

answered Jan 18, 2019 by Shubham
• 13,370 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Unable to start Bluemix MobileFirst services starter app

 Having used both the Classic UI and the "New Experience" ...READ MORE

answered Sep 11, 2018 in IoT (Internet of Things) by Annie97
• 2,200 points
47 views
0 votes
1 answer

Python Code to retrieve data from Device to IBM Bluemix

You connect as a device -> import ibmiotf.device. ...READ MORE

answered Sep 18, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
225 views
0 votes
1 answer

Downloading source code of Android Things

No because AndroidThings is still in preview ...READ MORE

answered Jul 5, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
621 views
0 votes
1 answer

URL Scheme for iOS Home App

I think you could try doing it ...READ MORE

answered Nov 16, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
116 views
0 votes
1 answer

Detecting BLE beacons that are not ibeacons on IOS

You'll have to understand that CoreLocation is ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
103 views
0 votes
1 answer

Using Post and Get for Embedded System Communication

Twitter would be a great place to ...READ MORE

answered Sep 4, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
79 views
0 votes
1 answer

Get User Group in Swift using AWS Cognito

The groups are exposed in the ID ...READ MORE

answered Nov 12, 2018 in AWS by Priyaj
• 57,530 points
404 views
0 votes
1 answer

How to detect presence of a device in a WiFi network?

Finding the mac-address would probably work. Basically, ...READ MORE

answered Nov 16, 2018 in IoT (Internet of Things) by Shubham
• 13,370 points
404 views
0 votes
1 answer

Detecting when a sensor is not sending data to Orion CB in FiWARE

Orion in itself has no such mechanism ...READ MORE

answered Nov 21, 2018 in IoT (Internet of Things) by Shubham
• 13,370 points
50 views