Ejemplo n.º 1
0
    def send_notification(self, auction_id, bid_value):
        customers = self.db.customers.find({"auction": auction_id})

        for doc in customers:
            toast = MPNSToast()
            tile = MPNSTile()
            toast.send(doc["channelURI"], {'text1': 'Nova oferta', 'text2': 'Com o valor ' + str(bid_value) + ' eur'})
            tile.send(doc["channelURI"], {'title': 'Nova oferta no valor de ' + str(bid_value) + ' eur'})
    def pushMessage(self, message, destToken, channel_name):
        send_count = len(destToken)
        sent = 0
        if send_count > 0:

            toast = MPNSToast()

            # Nota il body per sicurezza va mandato solo in versione "short" per il tile
            # ma i dati del messaggio li prende l'app con una get sull'id
            paramString = "?body=" + urlquote(message.alert_msg) + "&push_type=" + message.push_type + "&"

            for k in message.data_dic:
                paramString += k + "=" + str(urlquote(message.data_dic[k])) + "&"

            for tok in destToken:
                toast.send(tok, {"text1": message.alert_msg, "text2": "Pushetta", "param": paramString[:-1]})
                sent = sent + 1
        else:
            self.log_info("Nothing to send for WP8PushProvider")

        return sent
Ejemplo n.º 3
0
def push_to_phone(url):
    # url = 'http://s.notify.live.net/u/1/db5/H2QAAADBo0z35_dUsgo59XYi1_gtBNEKl0FDd9ZkNeItvz3P-3-bjt3NIdQWgPRZOK46G2mHlmdk1Va0sGZYeSFxlivk_S6DYnKHP-BDcPwk_ZfNu_vBJwyFEjgvoNn-TnjkL4E/d2luZG93c3Bob25lZGVmYXVsdA/QSX_vdQXKUm4Ttff9DP9cw/8Cc1wncyNMvaOjpvUn2Ezrro-CY'
    toast = MPNSToast()
    toast.send(url, {"text1": "Smart alarm", "text2": "Wake up!"})
Ejemplo n.º 4
0
 def test_prepare_toast_payload(self):
     test_toast = MPNSToast()
     payload = {'text1': 'Дядя Фёдор, а у тебя только один неправильный бутерброд был?'}
     prepared = self.XML_TOAST.format(**payload).encode('utf-8')
     assert test_toast.prepare_payload(payload) == prepared