Skip to main content

Like Pushkin, but subscribe to GCM/FCM and receive notifications

Project description

Pullkin

CodeFactor Build Status FOSSA Status PyPI - Downloads GitHub GitHub last commit PyPI - Python Version

Like Pushkin, but subscribe to FCM (GCM) and receive notifications

My alternative implementation of python implementation of JS implementation

Tested on python (3.6, 3.8, 3.10, pypy3.7-7.3.5)

I almost didn't write anything to consider it my intellectual property, just wrapped the code already written by Franc[e]sco in a design convenient for my own use

Note that for the listening part Franc[e]sco has to pull in http-ece which depends on a full-blown native crypto library rather than just oscrypto. it is an optional dependency, so you'll have to install it explicitly by depending on pullkin[listen]

Differences

  • Add async listener
  • Add async listener-coroutine
  • Replace functions with class of listener

Usage

Installation

pip install pullkin

How to use

import asyncio

from pullkin import AioPullkin
from pullkin.models.message import Message

pullkin = AioPullkin()

with open(".persistent_ids.txt", "r") as f:
    received_persistent_ids = [x.strip() for x in f]


@pullkin.on_notification()
async def on_notification(obj, message: Message, data_message):
    idstr = data_message.persistent_id + "\n"
    with open(".persistent_ids.txt", "r") as f:
        if idstr in f:
            return
    with open(".persistent_ids.txt", "a") as f:
        f.write(idstr)
    print(message.notification)


async def main():
    await pullkin.listen_forever()


asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pullkin-0.8.4.tar.gz (21.3 kB view hashes)

Uploaded Source

Built Distribution

pullkin-0.8.4-py3-none-any.whl (25.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page