Ejemplo n.º 1
0
 def setUpClass(cls):
     # Ignore all log messages so that test output is not cluttered.
     logging.basicConfig(level=logging.CRITICAL)
     cls.tokens = ['%064x' % i for i in range(10000)]
     cls.payload = Payload(alert='Test alert')
     cls.notifications = [
         Notification(token=token, payload=cls.payload)
         for token in cls.tokens
     ]
     cls.topic = 'com.example.App'
Ejemplo n.º 2
0
 def sendMessages(self, apnTokens, message, custom):
     payload = Payload(alert=message,
                       sound="default",
                       custom=custom,
                       content_available=1)
     notifications = [
         Notification(token=token, payload=payload) for token in apnTokens
         if token != None
     ]
     self.client.send_notification_batch(notifications, self.topic)
Ejemplo n.º 3
0
def pushSecurityIOS(tokens, community, site):
    notification = {
        "loc-key": Msg_Type.IM,
        "command": Msg_Cmd.SECURITY,
        "device-system": community,
        "device-name": site
    }
    notifications = [
        Notification(token=token, payload=Payload(alert=notification))
        for token in tokens
    ]
    pushIOS(notifications)
Ejemplo n.º 4
0
 def apns_send(tokens, data):
     if current_app.config['TESTING'] is True:
         current_app.config['TESTING_APNS'].append(data)
         return
     payload = Payload(alert=data['service']['name'],
                       sound="default",
                       badge=1,
                       custom=data)
     notifications = [
         Notification(token=token, payload=payload) for token in tokens
     ]
     topic = 'me.elrod.iPushjet'
     client = APNsClient(apns_cert_path,
                         use_sandbox=True,
                         use_alternative_port=False)
     client.send_notification_batch(notifications, topic)
Ejemplo n.º 5
0
def notifications(tokens):
    payload = Payload(alert='Test alert')
    return [Notification(token=token, payload=payload) for token in tokens]
Ejemplo n.º 6
0
 def clearNotifications(self, apnToken):
     payload = Payload(alert=None, badge=0, custom={'type': 'clear'})
     notifications = [Notification(token=apnToken, payload=payload)]
     self.client.send_notification_batch(notifications, self.topic)