Core API

class pushka.BaseService(*, loop)[source]

Base sender service class.

Parameters:loop – asyncio event loop or Tornado IOLoop
new_http_client()[source]

Create new http client.

If service is running on Tornado IOLoop, then tornado.httpclient.AsyncHTTPClient is used. When asyncio event loop is specified aiohttp client is used, in that case aiohttp library is required to be installed.

class pushka.BasePushService(*, loop)[source]

Push notifications sender interface class mixin.

Provides empty methods for push notifications sender, which should be implemented in subclasses.

Usage example:

from pushka import BasePushService

class ParsePushService(BasePushService):
    """Send push notifications via Parse service."""
    @asyncio.coroutine
    def send_push(self, token=None, device_type=None, tags=None,
                  alert=None, badge=None, sound=None, **kwargs):
        do_something()
        # ...
add_tags(token=None, tags=None)[source]

Add tags for registered device token, it may also be considered as subscribing to channel. Returns updated list of tags. Coroutine.

add_target(token=None, device_type=None, tags=None)[source]

Register target device push token. Coroutine.

del_tags(token=None, tags=None)[source]

Remove tags for registered device token, it may also be considered as unsubscribing from channel. Returns updated list of tags. Coroutine.

del_target(token=None, device_type=None, tags=None)[source]

Unregister target device push token. Coroutine.

get_tags(token=None, tags=None)[source]

Get tags for registered device token. Returns list of tags. Coroutine.

send_push(token=None, device_type=None, tags=None, alert=None, badge=None, sound=None, **kwargs)[source]

Send push message to single or multiple devices specified by filtering options. Coroutine.

Parameters:
  • token (str) – Device token string
  • device_type (str) – Device type: ‘ios’ / ‘android’
  • tags (list) – List of string tags / channels
  • alert (str) – Notification alert text
  • badge (int, optional) – Application badge number to set
  • sound (str, optional) – Sound name to play, use ‘default’ for system sound
class pushka.BaseMailService(*, loop, default_sender=None)[source]

Email sender base class.

Provides empty method for email sender, which should be implemented in subclasses.

Parameters:
  • loop – asyncio event loop or Tornado IOLoop
  • default_sender (str) – default sender’s email address

Usage example:

from pushka import BaseMailService

class SESMailService(BaseMailService):
    """Send email via Amazon SES service."""
    @asyncio.coroutine
    def send_mail(self, subject='', body=None, recipients=None, sender=None,
                  html=None, attachments=None, reply_to=None,
                  cc=None, bcc=None, **kwargs):
        do_something()
        # ...
send_mail(text=None, subject='', recipients=None, sender=None, html=None, attachments=None, reply_to=None, cc=None, bcc=None, return_path=None, **kwargs)[source]

Send email message. Coroutine.

Parameters:
  • text (str) – Plain text message in UTF-8 encoding
  • subject (str) – Subject string, must be single line string
  • recipients (list) – List of recipients email adresses
  • sender (str, optional) – Sender address or default will be used
  • html (str, optional) – HTML message in UTF-8 encoding
  • reply_to (str, optional) – Reply-to address
  • cc (str, optional) – Cc list
  • bcc (str, optional) – Bcc list
class pushka.BaseSMSService(*, loop, default_sender=None)[source]

SMS sender base class.

Provides empty method for SMS sender, which should be implemented in subclasses.

Parameters:
  • loop – asyncio event loop or Tornado IOLoop
  • default_sender (str) – default sender’s phone number

Usage example:

from pushka import BaseSMSService

class TwilioSMSService(BaseSMSService):
    """Send SMS via Twilio service."""
    @asyncio.coroutine
    def send_sms(self, text=None, recipients=None, sender=None):
        ...
send_sms(*, text, recipients, sender=None)[source]

Send SMS. Coroutine.

Parameters:
  • text (str) – Plain text message in UTF-8 encoding
  • recipients (list) – List of recipients phone numbers in format [‘+13334445577’, ...]
  • sender (str) – Sender phone number or default one will be used
class pushka.ParsePushService(*, loop, app_id, api_key, gcm_sender_id)[source]

Push notifications sender, which uses Parse service.

Parameters:
  • loop – asyncio event loop or Tornado IOLoop
  • app_id – Parse application ID
  • api_key – Parse Rest API key for application
add_target(*, token, device_type, tags=None)[source]

Register device token at Parse service.

See BasePushService.add_target() method docs for parameters reference.

send_push(*, alert, device_type, token=None, tags=None, badge=None, sound=None, title=None)[source]

Send push notification via Parse service.

See BasePushService.send_push() method docs for parameters reference.