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!

Friday, April 29, 2016

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

In the previous post we saw how we could setup the Google Form to write to Google Sheet.

We will need 2 additional steps to submit information to Google Form from iOS app.

  • Extract the various identifiers (like URL, field id etc) of Google Form
  • Use the identifiers in the iOS app to do an HTTP POST to Google Form
In this post we will focus on the first step only.

Extract Identifiers From Google Form

  • All we need to do is click on the "Preview" button on our google form page.

  • It should open up our form as below

  • Right click on the form and say "Inspect".

  • If you are using Chrome brows, it should open up a panel below the page which looks something like this

  • Find a tag called "<form>" in the panel, there you should look for "action" attribute.  This attribute has a big URL as its value.  Save this URL we will to POST to this URL from our iOS app.

  • Next, Right click on the input field in your form and click "Inspect".  It should show "input" tag highlighted in the panel below.

  • We are not really interested in the input tag that the panel is showing, 
  • We need to find another input tag which is of 'type="hidden"'.  This input tag would be 8-9 lines below the input tag currently highlighted

  • Note down the value of "name" attribute on the input.  Do the same thing for other fields in the Google Form.  These keys will be used when we submit information from our iOS app to this form.

Once we have these identifiers noted we are left with one last step i.e. to do the HTTP POST from iOS app to Google Forms.  We will see how to do that in the next post.

Thursday, March 31, 2016

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

Recently we wanted to write some information to Google Sheet from our iOS app Monster Math.

There does exist an Objective C library that could directly write to the Google Sheet, but the API it exposes did look cumbersome.  What we did instead was a very simple hack.

  • We setup a Google Form with all the information we wanted to write to the Google Sheet.  
  • We then configured Google Form to write the responses to a Google Sheet.
  • This enabled us to directly submit information to Google Form using HTTP POST and responses will get written to Google Sheet automatically!
In this series I will explain how we could do the above steps.

Creating the Google Form

This is gonna be the super easy part.  
  • Login with you google account here
  • Click the big Plus icon to add a new form
  • Set the title as "My Survey".  If you want you can also add optional form description.

  • Next its time to setup questions which will act as columns in your Google Sheet
  • Lets setup two questions "Name" and "Age".
  • Enter "Name" in the text field that reads "Question"
  • Change the type of the Question from "Multiple Choice" to "Short Answer"

  • Similarly add one more question with title "Age" and of type "Short Answer".
  • After the setup your from should look like the image below.

Our Google Form is ready for use.  Now we just need to link it with a Google Sheet so that our responses get written there.

Link Google Form with a backing Google Sheet
  • Click on the "Responses" tab.
  • There you should see a green Google Sheet icon, click that.

  • It should prompt you to create a new Google Sheet with name "My Survey (Responses)", create it.

  • This should open up a Google Sheet which looks something like the image below.


Thats about it, you have successfully setup Google Forms to write its responses to Google Sheet.  You can verify the setup by clicking the preview icon on the Google Form.

It should open up the form which should look like the image below

Go ahead and submit some dummy information to test the setup.  This information should be written to the Google Sheet automatically.

Congratulation on reaching this far, the configuration part is over.  All we need to do is hook up this form from iOS app, we will cover that in the next post. 

Monday, February 29, 2016

North Karnataka - The Rome of India - Part 4

In my previous post, I narrated what fun it was to see the beautiful caves of Badami, Pattadakal and Aihole.  In this post we will experience, how mesmerising it was to visit the crown jewel of all these places -- Hampi!

Day - 4 - Hampi

As usual, we started early and we decided start our day by visiting the Stone Chariot at Vittala Temple Campus.  Boy, was it amazing to see this temple!  We took the services of a professional guide and struck a deal with him to show us all major monuments at Hampi during the day (highly recommended).

The architecture and history behind the Vittala Temple is magnificent.  Even after so many years, so many part of the temple are intact!

Stone Chariot @ Hampi
We also saw the musical pillars in the complex and the guide actually played music using only the stone pillars!

Musical Pillars @ Hampi
Next we went to Virupaksha Temple

Virupaksha Temple @ Hampi
Some of the sculptures still had their natural colors intact!

Natural Colors on sculptures @ Hampi
Close by is the Statue of Ugra Narsimha.

Ugra Narsimha @ Hampi
Next, we saw the beautiful Lotus Palace

Lotus Palace @ Hampi
and Elephant Stable

Elephant Stable @ Hampi
We saw many other places, what I have presented here are not even the highlights.  The history and monuments of Hampi have a lot to offer for everyone.

The rich history of Hampi and the sheer fact that there are so many ancient monuments (in great shape) at Hampi, makes it the Rome of India!  This whole trip filled our hearts with happiness and unforgettable memories of these fantastic places.  Next day, although very reluctantly, we had to go back to Bangalore and continue with our boring lives!

I hope you have enjoyed seeing the glimpse of these places as much as I have enjoyed visiting them! Here are the links (Part 1, Part 2, Part 3) to my previous posts that cover the entire series of North Karnataka - The Rome of India.

Friday, January 29, 2016

North Karnataka - The Rome of India - Part 3

In my previous post, I described what we saw at the historic city of Bijapur.

In this post, I will narrate what fun it was to see the beautiful caves of Badami Pattadakal and Aihole.

Day - 3 - Badami

We woke up early and decided to visit the famous cave temples of Badami since, it would be much easier to climb up during the early hours of the day.  There are 4 cave temples at Badami.

The idols and carvings are superb, it takes you back in the time when they were actually made.  So much effort would have been put to carve these beautiful sculptures out of rocky mountains.
Beautiful idols at Badami Cave Temples
Beautiful idols at Badami Cave Temples
Beautiful idols at Badami Cave Temples
 On the other side of the cave temples there is a beautiful lake.  On one edge of the lake you can see beautiful Shiva temple standing in all its glory.
Superb lake on the other side of Badami Cave Temples

Shiva Temple at the edge of the lake
Visiting the cave temples was an enchanting experience.  We then headed towards Pattadakal Temples.

Pattadakal & Aihole

You got to see this to believe it, this temple complex has many ancient temples which are very well kept.  Services of a guide are highly recommended here.
Temple Complex at Pattadakal
There are many stories carved out into these temples.  Entire Ramayana and Mahabharata have been carved on some stones.
Ramayana carved on stone
After Pattadakal, we marched on and reached Aihole to see the famous horseshoe shaped Durga temple.
Horseshoe shaped Durga temple at Aihole
The places we covered today were simply mind blowing, each one had rich history behind them.  The fact that they are all in this great shape after so many centuries, is just amazing.

Finally at about 1930 hrs we reached our hotel near Hampi.  After yet another amazing day, we were all very excited to see what Hampi has to offer us the next day!

Wednesday, December 30, 2015

North Karnataka - The Rome of India - Part 2

In my previous post, I narrated how we started our trip to explore North Karnataka and visited Almatti Dam on our way towards Bijapur.

In this post, I will describe what we was at the historic city of Bijapur.

Day - 2 - Bijapur

It was fully packed eventful day ahead of us.  We started at about 1030 hrs and reached Gol Gumbaz.  There we got into conversation with local "horse cart - cab drivers".  They seemed to offer us a good deal,

  • They would take us to all the famous places in Bijapur in their horse cart 
  • Tell us a bit of history about these places.  
  • All this for some 800-1000 Rs.  
  • That sounded great because, I would not have to drive the big car in city traffic and look for parking all the time!
We almost instantly decided to take the deal and start off.  The first place we visited was the Bijapur Jama Masjid.  It was an humongous mosque where nearly 20000 people could offer prayers!  The building was beautiful and well maintained.

Jama Masjid - Bijapur
Next they took us to Jod Gumbaz, Ibrahim Roza, Malik-e-Maidan and Bara Kaman.  Ibrahim Roza was the crown jewel of all these places.  Its a beautiful monument built on a single rock bed, it is noted for the symmetry of its features. It is said that the design for the Ibrahim Roza served as an inspiration for that of the famous Taj Mahal.

Ibrahim Roza - Bijapur
Finally, they dropped us to Gol Gumbaz and we could hardly wait to see the biggest dome ever built in India, next in size only to St Peter's Basilica in Rome.

We hired a professional guide (highly recommended) to see this monument in detail.  He showed us the central chamber, where every sound is echoed seven times!  

Then he took us to the top of the monument to see the Whispering Gallery.  There are around 7 stories in this monument.  The cross ventilation (or whatever you want to call it) is so well designed that even at 45 C summer heat, the constant flow of cool breeze through the windows keeps you cool!

Once at top, we obviously wanted to witness and experience the Whispering Gallery.  Its said that even minute sounds can be heard clearly 37 meters away!  

The guide made us stand at one spot and he went and stood diagonally opposite (some 37 meters away) to where we were standing.  Amazingly, we could hear even the most minute sounds he was making at the other end - like lighting of a match stick!

Gol Gumbaz - Bijapur
All the monuments we saw at Bijapur where very well maintained.  By the time we finished visiting the Gol Gumbaz it was already 1500 hrs.  We decided to grab some quick lunch and then started our journey towards Badami.  We reached our hotel, had some nice dinner and crashed into bed.  Next morning we had to see the beautiful cave temples of Badami and much more!

In the next post, will describe what we saw at Badami. 

Monday, November 30, 2015

North Karnataka - The Rome of India - Part 1

It was Diwali of 2015 and we decided to take some time off and do 5 day road trip to North Karnataka.  Decided to visit these cities in particular Bijapur, Badami and Hampi.  I booked a nice and comfortable XUV W6 ZoomCar for this trip.

Before the trip, I had very low expectations from the places we were visiting.  I thought, mostly we will see almost destroyed and not well kept monuments.  But, was I in for a pleasant surprise!  The places were extremely well kept and monuments were beautiful and showing off their glorious past!

The route we had taken can be found here, round trip of around 1200 KM in 5 days and I was very much looking forward to have a nice time on the road!

Day - 1 - Bangalore to Bijapur

First day was mostly driving from Bangalore to Bjiapur, around 550 KM.  We started at about 0730 hrs, it was only 1630 hrs and we were only 70 KM away from Bijapur.  We took a slight detour and visited the Almatti Dam.  Its a beautiful dam with easy access to the dam's reservoir.  One could take a dip into clean dam waters and have some fun.  Were luck to see a beautiful sunset at the reservoir!

The dam also has a beautiful and super well kept garden with lots of fountain and lights and stuff.

Spent the evening there and we resumed our journey towards Bijapur.

It was Diwali day, all restaurants were closed by the time reached Bijapur - at about 2030.  We had tough time finding dinner, but eventually we did find one Restaurant who was ready to cook something for us.  It seems there is some tradition, all restaurants close their kitchens after the Diwali Puja is done - obviously I didn't know about it :P.

We crashed into the bed soon after dinner, next day was all jam packed and we were very much looking fwd for it!

In the next post, will describe what we saw at Bijapur.
Have some Fun!