2013年1月24日 星期四

使用GCM服務(二) 申請GCM API Key

1. 取得Google API project專案號碼
連線到Google APIs Console(https://code.google.com/apis/console)頁面,可使用之前建立的Google API project,或點選「Create…」另外建立一個Google API project。
檢視瀏覽器的網址列,URL會類似下列樣式: https://code.google.com/apis/console/#project:4815162342 
記下「#project:」後面的編號(例如4815162342),後續在GCM應用程式中需要使用這個號碼做為GCM的SENDER_ID。 

2.  啟用GCM服務
由Google APIs Console頁面點選「Services」,再由Services清單中將「Google Cloud Messageing for Android」項目切換為「ON」。
3. 取得GCM API key
由Google APIs Console頁面點選「API Access」,按下右側面板中的「Create new Server key」按鈕,然後在「Accept requests from these Server IP addresses:」欄中輸入訊息推播伺服器的IP。
4. 記下GCM API key,後續傳送請求到GCM Server時需要使用這個GCM API key。