안녕하세요
GCM 관련해서 http://developer.android.com/google/gcm/gs.html 링크를 봐가면서 작업을 하고 있는데
좀 난해한 부분이 있어서 질문드립니다. 구글에서 제공하는 GCM 레퍼런스 인데..
이러한 부분이 있습니다.
Sending a message
When the user clicks the app's Send button, the app sends an upstream message using the newGoogleCloudMessaging
APIs. In order to receive the upstream message, your server should be connected to CCS. You can use the code shown in Writing the Server Code as a sample XMPP client to connect to CCS.
서버쪽으로 업스트림 메시지를 전송하기 위한 부분인 것 같은데요.. 그런데 바로 아래에 보면...
As described above in Step 1, the app includes a broadcast receiver for thecom.google.android.c2dm.intent.RECEIVE
intent. This is the mechanism GCM uses to deliver messages. WhenonClick()
calls gcm.send()
, it triggers the broadcast receiver's onReceive()
method, which has the responsibility of handling the GCM message. In this sample the receiver's onReceive()
method calls sendNotification()
to put the message into a notification:
위와 같은 설명이 있는데 대충 gcm.send 함수를 콜하면 onReceive 메소드를 호출해서 메시지를 notification 하겠다는 말인데...왜 서버에게 업스트림 메시지를 전송하기 위한 부분을 클라이언트 어플쪽 리시버에서 처리하는 지 ,,,,
분명 CSS서버에게 upstream message를 send하면 onReceive를 호출하여 sendNotification해서 알림을 주겠다는 것인데...이 구조가 지금 어플에서 업스트림 메시지를 서버에게 전송하고 서버는 다시 앱에게 다운스트림 메시지를 전송하기 때문에 onReceive쪽에서 메시지를 받아서 처리한다는 말인가요?
긴글 죄송합니다.