2

這是如何被從服務器發送的消息:檢索GCM消息意圖的「內容」。

 //Queue Android GCM Notification 
     _pushService.QueueNotification(NotificationFactory.AndroidGcm() 
      .ForDeviceRegistrationId(device) 
      .WithCollapseKey("LATEST") 
      .WithJson("{\"alert\":\"" + message + "\",\"badge\":\"7\"}")); 

我收到的意向,我怎麼得到的消息?我想:

Log.d(TAG, "" + intent.getStringExtra("{\"alert\":\"")); 
    Log.d(TAG, "" + intent.getStringExtra("LATEST")); 
    Log.d(TAG, "" + intent.getStringExtra("data")); 

全部是空的,什麼消息文本價值的關鍵?

回答

3

知道了,其

Bundle b = intent.getExtras(); 
Set<String> allThatsInThere = b.keySet(); 
+1

'Bundle'沒有'getKeys()'功能;它應該讀取'keySet()'。 – 2013-09-13 15:16:31