mercredi 27 mai 2015

Sending extra parameters in GCM Payload in Python using AWS SNS

I'm using Amazon SNS to push message. I was successfully able to send plain text to the device in python using

conn_sns.publish(message='text msg',target_arn=device_arn,message_structure='')

I want to send a JSON-format message and I would like to send extra payload parameters but I was unsuccessful. Till now I've tried the following:

    gcm_dict = {'data':{},'com_msg':'Test message in json'
                        ,'com_arn':'12345'
                        ,'com_smi':'1453267868+12323445'}
    gcm_string = json.dumps(gcm_dict,ensure_ascii=False)

    message={'default':'default message','GCM':gcm_string}
    messageJSON = json.dumps(message)

    p = conn_sns.publish(message=messageJSON,target_arn=device_arn,message_structure='json')

I want to receive the extra parameters on my device but I was unable to receive the JSON message. Please tell me what I'm doing wrong.




Aucun commentaire:

Enregistrer un commentaire