11
我正在使用以下webservice從Android發送推送通知。當我第一次撥打此網絡服務時,需要很長時間並且推送通知不會在Android設備上傳送。它只有在從Android調用時纔會發生。它完美地作爲web服務。Android通過.net webservices發送推送通知
[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;
}
理想的情況下它不應該,但你可以檢查你的代碼與測試回聲服務器,而不是谷歌服務器的工作原理也是如此。 – the100rabh
可能是由於限制http://developer.android.com/google/gcm/adv.html#throttling – Slartibartfast