サーバー側でGCMプッシュサービスを実装していて、GCM => Error=MissingRegistrationからの応答でエラーに直面しています
このエラーが発生する理由を誰かが知っていますか?
サンプルコードは次のとおりです。
def make_request(self, data, is_json=True):
headers = {
'Authorization': 'key=%s' % self.api_key,
}
# Default Content-Type is defaulted to application/x-www-form-urlencoded;charset=UTF-8
if is_json:
headers['Content-Type'] = 'application/json'
if not is_json:
data = urllib.urlencode(data)
req = urllib2.Request(GCM_URL, data, headers)
try:
response = urllib2.urlopen(req).read()
except urllib2.HTTPError as e:
if e.code == 400:
raise GCMMalformedJsonException("The request could not be parsed as JSON")
elif e.code == 401:
raise GCMAuthenticationException("There was an error authenticating the sender account")
except urllib2.URLError as e:
raise GCMConnectionException("There was an internal error in the GCM server while trying to process the request")
if is_json:
response = json.loads(response)
return response
if __name__ == '__main__':
data = {
'param1': '1',
'param2': '2'
}
_gcm = GCM('AIzaSyC0lft1_11RGk2aMyt6hoNolC3in5rN50Y')
res = _gcm.construct_payload(
registration_ids=['APA91bF9MFLWBhZ7y4F87z0D8enceLxOD1GLl92cQSF9lp5Z-VlhxX'], data=data, collapse_key='foo',
delay_while_idle=True, time_to_live=3600, is_json=True
)
payload = json.loads(res)
result = _gcm.make_request(payload, False)