completed sample code for gcm