LoginSignup
10
15

More than 5 years have passed since last update.

PythonでiOSアプリにプッシュ通知を送ろう

Posted at

パッケージ

pyapns

環境

Python2.7.11

準備

$ sudo pip install pyapns
$ twistd -r epoll web --class=pyapns.server.APNSServer --port=7077

サンプルコード

from pyapns import configure, provision, notify
configure({'HOST': 'http://localhost:7077/'})
provision('app-name', open('cert.pem').read(), 'sandbox')
payload = {'aps': {
                'alert': {
                    'sound': 'default',
                    'badge': 0,
                    'body': 'Hello World!',
                    'message': 'Push Notification from Python!!'
                },
                'uri': 'https://nnsnodnb.moe'
            }}
notify('app-name', 'hexlified_token_str', payload)

これだけで開発中に簡単にプッシュ通知テストできるのはいいですね!!

10
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
15