I use pushwoosh for notification for the ios. The notifications works now, but it sends now to all devices. How can I use a filter with python to send only to specific user?

Thanks for the help.

asked 26 Jul '15, 20:52
dolcegabie's gravatar image

dolcegabie
112

How to do it:

def wooshmessage(request, message):

#set here your settings
PW_APP_CODE = ''
PW_AUTH_API = ''
PW_HWID_USER = ''
PW_TOKEN_USER = ''


pw_call('createMessage', {
    'auth': PW_AUTH_API,
    'application': PW_APP_CODE,
    'hwid' : PW_HWID_USER, 
    'notifications': [{
        'send_date': 'now',
         'content': 'overwinning',
            'data': {"custom": "json data"},
            'link': 'index.html',
            'ios_badges': '+1',
            'conditions': [['Username', 'EQ', 'john']]
        }
    ]
}
)

response = render_to_response('core/template.html', { 'context': context }) return response

permanent link
answered 27 Jul '15, 12:50
dolcegabie's gravatar image

dolcegabie
112

edited 27 Jul '15, 12:54

But before I use this, I make my own tag on pushwoosh.com. I name it "Username". You can register your new tag with this code in python:

pw_call('setTags', {
    'application': PW_APP_CODE,
    'push_token': PW_TOKEN_SERAJA,
    'hwid' : PW_HWID_SERAJA,
    'tags': { 'Username' : 'john'}
}
)
permanent link
answered 27 Jul '15, 12:52
dolcegabie's gravatar image

dolcegabie
112

I forget to write down the function pw_call:

def pw_call(method, data): url = 'https://cp.pushwoosh.com/json/1.3/' + method data = json.dumps({'request': data}) req = Request(url, data.encode('UTF-8'), {'Content-Type': 'application/json'}) try: f = urlopen(req) response = f.read() f.close() print('Pushwoosh response: ' + str(response)) except Exception as e: print ('Request error: ' + str(e))

permanent link
answered 27 Jul '15, 12:52
dolcegabie's gravatar image

dolcegabie
112

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×446
×353
×23

question asked: 26 Jul '15, 20:52

question was seen: 885 times

last updated: 27 Jul '15, 12:54