본문 바로가기

.Net

[Server] GCM 전송 Request 및 Response 분석 (C#)

  • 요약

 - 결과
 1. 유효하지 않은 registration_ids 이나 해당 단말기가 최종적으로 다시 어플을 설치하여 정상 push를 받을 수 있는 경우
     여기서 "32" 값은 다시 어플을 설치하여 정상 push를 받을수 있는 registration_ids 이다.
     : { "message_id": "1:2342", "registration_id": "32" }
 2. 유효하지 않은 registration_ids 이면서 해당 단말기에 어플을 삭제 후 설치하지 않은 경우
     : { "error": "NotRegistered"}
 3. 유효한 registration_ids  인경우
     : { "message_id": "1:1516" }
 4. GCM에 정상 발송하지 못해 재전송이 필요한경우
     : { "error": "Unavailable" }
 5. 복구할수 없는 오류가 있는 경우
     : { "error": "InvalidRegistration" }
 
 - 서버 적용 사항
  1번의 경우
   : 해당 index의 request의 registration_id를 DB에서 삭제/미사용 처리.
  2번의 경우 
   : 해당 index의 request의 registration_id를 
DB에서 삭제/미사용 처리.
  3번의 경우
   : 성공처리
  4번의 경우
   : 재전송 또는 성공처리(별도 재발송버튼을 통해 재전송요청)
  5번의 경우
   : 해당 index의 request의 registration_id를 
DB에서 삭제/미사용 처리. 

 
 

Here are JSON results for 6 recipients (IDs 4, 8, 15, 16, 23, and 42 respectively) with 3 messages successfully processed, 1 canonical registration token returned, and 3 errors:
{ "multicast_id": 216, "success": 3, "failure": 3, "canonical_ids": 1, "results": [ { "message_id": "1:0408" }, { "error": "Unavailable" }, { "error": "InvalidRegistration" }, { "message_id": "1:1516" }, { "message_id": "1:2342", "registration_id": "32" }, { "error": "NotRegistered"} ] }
In this example:
  • First message: success, not required.
  • Second message: should be resent (to registration token 8).
  • Third message: had an unrecoverable error (maybe the value got corrupted in the database).
  • Fourth message: success, nothing required.
  • Fifth message: success, but the registration token should be updated in the server database (from 23 to 32).
  • Sixth message: registration token (42) should be removed from the server database because the application was uninstalled from the device.
Or if just the third message above was sent using plain-text format:
 
  • Request & Response Sample

  - 상황 1
    XXXXXXXXXX : 삭제이력은 있고, 현재 새로 APP 설치 
    YYYYYYYYYY   : APP  정상설치    
 
     "XXXXXXXXXX-1", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-2", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-3", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-4", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-5", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-6", 현재 유효한 토큰 아이디
    
     "YYYYYYYYYY-1", 현재 유효한 토큰 아이디

  - Request
{  "registration_ids":
     [
          "XXXXXXXXXX-1",
          "XXXXXXXXXX-2",
          "XXXXXXXXXX-3",
          "XXXXXXXXXX-4",
          "XXXXXXXXXX-5",
          "XXXXXXXXXX-6",
          "YYYYYYYYYY-1"
     ],
     "data":
     {                
          "message": "message 20150622 test 027",
          "url": "/test.html"
     }
}
 
  - Response
{
     "multicast_id":8056633087369018367,
     "success":7,
     "failure":0,
     "canonical_ids":5,

     "results":
          [
               {"registration_id":"XXXXXXXXXX-6",
               "message_id":"0:1435019039922838%518ed333f9fd7ecd"},
               {"registration_id":"XXXXXXXXXX-6",
               "message_id":"0:1435019039922835%518ed333f9fd7ecd"},
               {"registration_id":"XXXXXXXXXX-6",
               "message_id":"0:1435019039922835%518ed333f9fd7ecd"},
               {"registration_id":"XXXXXXXXXX-6",
               "message_id":"0:1435019039922835%518ed333f9fd7ecd"},
               {"registration_id":"XXXXXXXXXX-6",
               "message_id":"0:1435019039922680%518ed333f9fd7ecd"},
               {"message_id":"0:1435019039922682%518ed333f9fd7ecd"},
               {"message_id":"0:1435019039920376%518ed333f9fd7ecd"}

          ]
}
 
 
 

  - 상황2
     2개의 단말기 Request하는경우 
    XXXXXXXXXX : 삭제이력은 있고, APP  미설치  
    YYYYYYYYYY   : APP  정상설치    
 
     "XXXXXXXXXX-1", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-2", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-3", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-4", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-5", 이미 삭제한 어플의 유효하지 않은 토큰 아이디
     "XXXXXXXXXX-6", 이미 삭제한 어플의 유효하지 않은 토큰 아이디 
    
     "YYYYYYYYYY-1", 현재 유효한 토큰 아이디
   - Request
{  "registration_ids":
     [
          "XXXXXXXXXX-1",
          "XXXXXXXXXX-2",
          "XXXXXXXXXX-3",
          "XXXXXXXXXX-4",
          "XXXXXXXXXX-5",
          "XXXXXXXXXX-6",
          "YYYYYYYYYY-1"
     ],
     "data": {                
          "message": "message 20150622 test 051",
          "url": "/test.html"
     }
}
 
  - Response
{
     "multicast_id":6861312777568674149,
     "success":1,
     "failure":6,
     "canonical_ids":0,

     "results":
          [
               {"error":"NotRegistered"},
               {"error":"NotRegistered"},
               {"error":"NotRegistered"},
               {"error":"NotRegistered"},
                {"error":"NotRegistered"},
               {"error":"NotRegistered"}
               {"message_id":"0:1435020423686868%518ed333f9fd7ecd"}, 
           ]
}