def send(msg, summ, is_bullied, bully): gcm = GCM("AIzaSyDjXNoiS_0OzWwiajVsi1GIAJFvkN47qPk") data = {'message': msg, 'summ': summ, 'is_bullied' : is_bullied, 'bully' : bully} topic = 'global' gcm.send_topic_message(topic=topic, data=data) return
def send_push_mesage(msg, the_time): logging.getLogger('BoilerLogger').debug('sending boiler sms message: %s' % msg) gcm = GCM(PUSH_NOTIFICATION_API_KEY) data = {'message': msg, 'time': str(the_time)} topic = 'global' try: gcm.send_topic_message(topic=topic, data=data) except: logging.getLogger('BoilerLogger').debug('can not send push message, ignore.')
def send_push_mesage(msg, the_time): logging.getLogger('BoilerLogger').debug('sending boiler sms message: %s' % msg) gcm = GCM(PUSH_NOTIFICATION_API_KEY) data = {'message': msg, 'time': str(the_time)} topic = 'global' try: gcm.send_topic_message(topic=topic, data=data) except: logging.getLogger('BoilerLogger').debug( 'can not send push message, ignore.')
def gcm_python_gcm(): from gcm import GCM api_key = "AIzaSyATYMS-F-gZRNvp7Md108k_vRfm-TZvueY" gcm = GCM(api_key, debug=True) data = {'param1': 'value1', 'param2': 'value2'} topic = "SomeTopic" response = gcm.send_topic_message(topic=topic, data=data) return response
def send_gcm(request): ''' save user gcm registration id :param request: :return: ''' if request.method == "GET": return Response({"detail": "get is not supported"}) elif request.method == "POST": secret = Secret.objects.all().order_by('-id')[0] API_KEY = secret.api_key gcm = GCM(API_KEY) ##data = {'param1': 'value1', 'param2': 'value2'} data = request.data # Downstream message using JSON request ##reg_ids = ['token1', 'token2', 'token3'] tokens = GcmRegister.objects.all() reg_ids = [] for token in tokens: reg_ids.append(token.gcmToken) response = gcm.json_request(registration_ids=reg_ids, data=data) # Downstream message using JSON request with extra arguments res = gcm.json_request(registration_ids=reg_ids, data=data, collapse_key='uptoyou', delay_while_idle=True, time_to_live=3600) # Topic Messaging topic = 'global' gcm.send_topic_message(topic=topic, data=data) return Response({'detail': res})
def gcm_topic_send(self, cr, uid, topic,notification, conext=None): # Topic Messaging if not self.API_KEY: raise osv.except_osv(u'Alera', u'No se a configurado el API KEY de Google GCM') gcm = GCM(self.API_KEY) if not notification: notification={ "type": "Notificación de tópico", "message": "Tópico de Tandi GCM!" } if not topic: topic = 'tandigcm' response = gcm.send_topic_message(topic=topic, data=notification) print(response)
class CloudPush: def __init__(self): self._gcm = GCM("AIzaSyATYMS-F-gZRNvp7Md108k_vRfm-TZvueY", debug=True) self._data = {'param1': 'value1', 'param2': 'value2'} # # Downstream message using JSON request # reg_ids = ['token1', 'token2', 'token3'] # response = gcm.json_request(registration_ids=reg_ids, data=data) # # # Downstream message using JSON request with extra arguments # res = gcm.json_request( # registration_ids=reg_ids, data=data, # collapse_key='uptoyou', delay_while_idle=True, time_to_live=3600 # ) def send_topic(self, topic): response = self._gcm.send_topic_message(topic=topic, data=self._data) print(response)
#!/usr/bin/env python3 from gcm import GCM # Topic Messaging API_KEY = "your api key" gcm = GCM('api key') data = {'param1': 'value1', 'param2': 'value2'} topic = 'your topic name' response = gcm.send_topic_message(topic=topic, data=data) print(response)
def save(self, *args, **kwargs): gcm = GCM(settings.GCM_KEY) data = {'type': 'notify'} res = gcm.send_topic_message(topic="counter_" + self.name, data=data) super(Counter, self).save(*args, **kwargs)
# -*- coding:utf-8 -*- from gcm import GCM gcm = GCM('AIzaSyB2UGIEf-3dVZvtT0CSXzTmrLhGCsMd1XE') data = {'message': u'아만다 아만다'} # Topic Messaging topic = 'global' gcm.send_topic_message(topic=topic, data=data)
from gcm import GCM #djm_HtyIxrM:APA91bHRza5mgE14gtRP06b_uv7JDgZ0bEcUBlIvgvgsH7pbsnWa3z5_aQLXRH7ehipw2-dCiFGC69zU9jWuiwzx4fVXFG-hWpdvEJCITJ5Eoe0Nf5eqFiSbLoJzNdT73tWG_OWD0yPZ gcm = GCM("AIzaSyA_LJj2iDD5sjTuJrPrkVrE6m-J-vasf9A", debug=True) token = "e322hEfMBdQ:APA91bEU6yveKVf9qYdEtZufs-86oTS9nasVdguu72lIH3dnjCtBeGO5zMfWWNDKBWfClhihLPwwhttZGX0b1ss7U4f42rJf8ax9BbZLlwSncR7Uk9hEX_HleR0LZkBAYFUBT141aBM1" token = "cmiH2Un57O0:APA91bES88EA3jnMpzcNlIMPt-LKz_8-EZC7KrlacTEZlO_tlk5wcmfdlI6RJDwvPgD0rFw1nc-4YU1bBzznTaQJBrngBRGSYcaLeAblwZCp2luGn_s3iN7f9CV95DWN3iEazzKmDbdf" data = { 'message': 'Le diner est a 20h. au choix: \n -poulet u fromage \n - comcombre de mer' } # Downstream message using JSON request reg_ids = ['token1', 'token2', 'token3'] response = gcm.json_request(registration_ids=[token], data=data) # Downstream message using JSON request with extra arguments res = gcm.json_request(registration_ids=reg_ids, data=data, collapse_key='uptoyou', delay_while_idle=True, time_to_live=3600) # Topic Messaging topic = 'topic name' gcm.send_topic_message(topic=topic, data=data)
#!/usr/bin/env python3 from gcm import GCM # Topic Messaging API_KEY = "your api key" gcm = GCM("api key") data = {"param1": "value1", "param2": "value2"} topic = "your topic name" response = gcm.send_topic_message(topic=topic, data=data) print(response)