I am using following webservice for sending Push notification from Android. When I call this webservice first time, it takes so much time and push notification is not delivered on Android Device. It happens only when called from Android. It works perfectly as webservice.
[WebMethod]
public string SendGcm(String serviceKey,String registrationId ,string message) {
WebClient wc=new WebClient();
wc.Headers.Add("Authorization", "key=" + serviceKey);
NameValueCollection nameValues=new NameValueCollection
{
{"registration_id", registrationId},
{"collapse_key", Guid.NewGuid().ToString()},
{"data.payload", message}
};
var resp=wc.UploadValues("https://android.googleapis.com/gcm/send",
nameValues);
var respMessage = Encoding.Default.GetString(resp);
return respMessage;
}