{"id":30700137,"url":"https://github.com/operasoftware/twisted-apns","last_synced_at":"2025-09-02T11:44:19.309Z","repository":{"id":62585709,"uuid":"36137337","full_name":"operasoftware/twisted-apns","owner":"operasoftware","description":"Twisted client for Apple Push Notification Service (APNs)","archived":false,"fork":false,"pushed_at":"2015-09-18T10:35:09.000Z","size":299,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-06-23T17:16:40.910Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/operasoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-23T18:44:15.000Z","updated_at":"2023-09-10T13:31:48.000Z","dependencies_parsed_at":"2022-11-03T22:02:33.706Z","dependency_job_id":null,"html_url":"https://github.com/operasoftware/twisted-apns","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/operasoftware/twisted-apns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operasoftware%2Ftwisted-apns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operasoftware%2Ftwisted-apns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operasoftware%2Ftwisted-apns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operasoftware%2Ftwisted-apns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/operasoftware","download_url":"https://codeload.github.com/operasoftware/twisted-apns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operasoftware%2Ftwisted-apns/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273279958,"owners_count":25077318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-02T11:43:36.883Z","updated_at":"2025-09-02T11:44:19.299Z","avatar_url":"https://github.com/operasoftware.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twisted client for APNs\n[![Build status](https://travis-ci.org/operasoftware/twisted-apns.svg)](https://travis-ci.org/operasoftware/twisted-apns)\n[![Version](https://img.shields.io/pypi/v/twisted-apns.svg)](https://pypi.python.org/pypi/twisted-apns)\n[![Code Climate](https://codeclimate.com/github/operasoftware/twisted-apns/badges/gpa.svg)](https://codeclimate.com/github/operasoftware/twisted-apns)\n\n## Overview\n*Twisted-APNs* is an implementation of provider-side client for Apple Push Notification Service, based on [official iOS documentation](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html). It uses [Twisted networking engine](https://twistedmatrix.com).\n\n## Features\n* Sending notifications through gateway service\n* Querying feedback service for failed remote notifications\n\n## Requirements\n* Python\u003e=2.7\n* Twisted (version 15.0.0 known to work)\n* pyOpenSSL\n\n## Download\n* [GitHub](https://github.com/operasoftware/twisted-apns)\n\n## Installation\nYou can install it easily from PyPi by single command:\n```\npip install twisted-apns\n```\nor clone source code and run:\n```\npython setup.py install\n```\n\n## Usage examples\n\n### Sending a notification\n\nFirst, do the necessary imports and set up logging for debug purposes:\n```python\nimport logging\n\nfrom apns.gatewayclient import GatewayClientFactory\nfrom apns.notification import Notification\nfrom twisted.internet import reactor\n\n\nlogger = logging.getLogger()\nlogger.setLevel(logging.DEBUG)\nlogger.addHandler(logging.StreamHandler())\n```\n\nThen create an instance of gateway client factory, specifying intended endpoint (`pub` for production or `dev` for development purposes), and setting a path to your provider certificate:\n```python\n# Make sure /apn-dev.pem exists or pass valid path.\nfactory = GatewayClientFactory('dev', '/apn-dev.pem')\nreactor.connectSSL(factory.hostname,\n                   factory.port,\n                   factory,\n                   factory.certificate.options())\n```\nThe code below sends a sample notification with JSON-encoded payload to device identified with supplied `token` (in hex):\n```python\ndef send():\n    token = '00'  # Set to something valid.\n    payload = {'aps': {'alert': \"What's up?\",\n                       'sound': 'default',\n                       'badge': 3}}\n    notification = Notification(token=token,\n                                expire=Notification.EXPIRE_IMMEDIATELY,\n                                payload=payload)\n    factory.send(notification)\n\nreactor.callLater(1, send)\nreactor.run()\n```\n\nIf `token` is valid console outputs:\n```\nGateway connection made: gateway.push.apple.com:2195\nGateway send notification\n```\n\n\nIf not (like `00`) error is returned:\n```\nGateway connection made: gateway.sandbox.push.apple.com:2195\nGateway send notification\nGateway error received: \u003cErrorResponse: Invalid token size\u003e\nGateway connection lost: Connection was closed cleanly.\nGateway connection made: gateway.sandbox.push.apple.com:2195\n```\n\n### Querying list of invalidated tokens\n\nThe following code connects to the feedback service and prints tokens which should not be used anymore:\n```python\nimport logging\n\nfrom apns.feedbackclient import FeedbackClientFactory\nfrom apns.feedback import Feedback\nfrom twisted.internet import reactor\n\nlogger = logging.getLogger()\nlogger.setLevel(logging.DEBUG)\nlogger.addHandler(logging.StreamHandler())\n\n# Make sure /apn-dev.pem exists or pass valid path.\nfactory = FeedbackClientFactory('dev', '/apn-dev.pem')\nreactor.connectSSL(factory.hostname,\n                   factory.port,\n                   factory,\n                   factory.certificate.options())\n\ndef onFeedbacks(feedbacks):\n    for f in feedbacks:\n        print \"It would be better to stop sending notifications to\", f.token\n\nfactory.listen(FeedbackClientFactory.EVENT_FEEDBACKS_RECEIVED, onFeedbacks)\n\nreactor.run()\n```\n\n## Contributing\nYou are highly encouraged to participate in the development, simply use GitHub's fork/pull request system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperasoftware%2Ftwisted-apns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foperasoftware%2Ftwisted-apns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperasoftware%2Ftwisted-apns/lists"}