예제 #1
0
 def process(self, **kwargs):
     token = kwargs['token']
     logging.info("APNS token is %s" % token)
     apnsparams = kwargs['apns']
     sound = apnsparams.get('sound', None)
     badge = apnsparams.get('badge', None)
     customparams = apnsparams.get('custom', None)
     pl = PayLoad(alert=kwargs['alert'],
                  sound=sound,
                  badge=badge,
                  identifier=0,
                  expiry=None,
                  customparams=customparams)
     logging.info(
         "ignoring airnotifier APNS and sending via pyAPNS instead...")
     mode = True if (glob_env == 'sandbox') else False
     print "PYAPNS DETAILS: %r %s %s " % (mode, self.certfile, self.keyfile)
     pyapns_connection = pyAPNs(use_sandbox=mode,
                                cert_file=self.certfile,
                                key_file=self.keyfile)
     pyapns_payload = pyPayload(alert=kwargs['alert'],
                                sound=sound,
                                badge=badge,
                                custom=customparams)
     print "PYAPNS MESSAGE: %s AND %s " % (pyapns_payload, token)
     pyapns_connection.gateway_server.send_notification(
         token, pyapns_payload)
예제 #2
0
 def __init__(self,
              env="sandbox",
              certfile="",
              keyfile="",
              appname="",
              db=""):
     certexists = file_exists(certfile)
     keyexists = file_exists(keyfile)
     if not certexists:
         logging.error("Certificate file doesn't exist")
     if not keyexists:
         logging.error("Key file doesn't exist")
     if not certexists and not keyexists:
         raise Exception("Cert or Key not exist")
     self.host = feedbackhost[env]
     self.certfile = get_filepath(certfile)
     self.keyfile = get_filepath(keyfile)
     self.ioloop = ioloop.IOLoop.instance()
     self.appname = appname
     #PP use pyAPNS to get feedback
     self.db = db
     logging.info("Invoking pyAPNs feedback to check channel")
     mode = True if (env == 'sandbox') else False
     feedback_connection = pyAPNs(use_sandbox=mode,
                                  cert_file=self.certfile,
                                  key_file=self.keyfile)
     # Get feedback messages.
     for (token_hex,
          fail_time) in feedback_connection.feedback_server.items():
         logging.info("feedback deleting token: %s expired at %s\n" %
                      (token_hex, fail_time))
         try:
             result = self.db.tokens.remove({'token': token_hex}, safe=True)
         except Exception as ex:
             logging.exception(ex)
예제 #3
0
    def __init__(self,  env="sandbox", certfile="", keyfile="", appname="", db=""):
        certexists = file_exists(certfile)
        keyexists = file_exists(keyfile)
        if not certexists:
            logging.error("Certificate file doesn't exist")
        if not keyexists:
            logging.error("Key file doesn't exist")
        if not certexists and not keyexists:
            raise Exception("Cert or Key not exist")
        self.host = feedbackhost[env]
        self.certfile = get_filepath(certfile)
        self.keyfile = get_filepath(keyfile)
        self.ioloop = ioloop.IOLoop.instance()
        self.appname = appname
	#PP use pyAPNS to get feedback
	self.db = db
	logging.info("Invoking pyAPNs feedback to check channel")
	mode = True if (env == 'sandbox') else False
	feedback_connection = pyAPNs(use_sandbox=mode, cert_file=self.certfile, key_file=self.keyfile)
	# Get feedback messages.
	for (token_hex, fail_time) in feedback_connection.feedback_server.items():
		logging.info( "feedback deleting token: %s expired at %s\n" %(token_hex, fail_time))
		try:
			result = self.db.tokens.remove({'token':token_hex}, safe=True)
		except Exception as ex:
                	logging.exception(ex)
예제 #4
0
    def process(self, **kwargs):
        token = kwargs['token']
	logging.info ("APNS token is %s" %token)
        apnsparams = kwargs['apns']
        sound = apnsparams.get('sound', None)
        badge = apnsparams.get('badge', None)
        customparams = apnsparams.get('custom', None)
        pl = PayLoad(alert=kwargs['alert'], sound=sound, badge=badge, identifier=0, expiry=None, customparams=customparams)
	logging.info ("ignoring airnotifier APNS and sending via pyAPNS instead...")
	mode = True if (glob_env == 'sandbox') else False
	print "PYAPNS DETAILS: %r %s %s " % (mode, self.certfile, self.keyfile)
	pyapns_connection  = pyAPNs(use_sandbox=mode, cert_file=self.certfile, key_file=self.keyfile)
	pyapns_payload = pyPayload (alert=kwargs['alert'], sound=sound, badge=badge, custom=customparams)
	print "PYAPNS MESSAGE: %s AND %s " % (pyapns_payload, token)
	pyapns_connection.gateway_server.send_notification(token,pyapns_payload)