我嘗試在我的項目中實現GCM,並且遇到onMessage函數的問題。根據例子,我寫道:Android GCM onMessage
@Override
protected void onMessage(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
Log.d("GCM", "RECIEVED A MESSAGE: " + arg1.getStringExtra("message"));
// other part of the code goes here...
}
那麼,我得到這個getStringExtra錯誤 - 它似乎這個意圖不包含它。我確實收到onMessage事件。嘗試獲取實際消息時,我只會遇到錯誤。 我的服務器接收:
{"multicast_id":7888157947681629492,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1348246306435688%196553bef9fd7ecd"}]}