Tuesday, May 31, 2016

How to write to Google Sheet from an iOS app - Part 3

In the previous post we saw how we could extract various identifiers from the Google Form.  We will use these identifiers from the iOS app to do HTTP POST and submit information to the Google Form.

How to do HTTP POST to Google Form from iOS App

This is by far the simplest step of all.  We will be using the open source iOS library AFNetworking for doing the actual POST.
  • We first need to build a dictionary of all the POST parameters we want to submit to Google Forms using the identifiers extracted in the previous post
  • Then we need to set proper request and response serializers
  • We need to set the content type as "text/html".  Thats because Google Form will return HTML response
  • And finally we need to make the actual POST call.  AFNetwork accepts success and failure callbacks will will be called depending on whether the call succeeded or failed.
Once this is setup, test it out, on successful POST the data should be getting written to the backing Google Sheet.

Thats all folks.  We have concluded our three part series of how to write to Google Sheet from an iOS App!
Have some Fun!