{"id":15023683,"url":"https://github.com/sunaoka/push-notifications-php","last_synced_at":"2026-02-18T04:01:00.387Z","repository":{"id":57061420,"uuid":"415894661","full_name":"sunaoka/push-notifications-php","owner":"sunaoka","description":"Push notifications Library for PHP","archived":false,"fork":false,"pushed_at":"2025-12-29T03:23:38.000Z","size":77,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T22:59:10.038Z","etag":null,"topics":["apns","apple-push-notifications","fcm","firebase-cloud-messaging","notifications","php","php55","php56","php70","php71","php72","php73","php74","php80","php81","push","push-notifications"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/sunaoka/push-notifications-php","language":"PHP","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/sunaoka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-10-11T11:23:25.000Z","updated_at":"2025-12-29T03:22:07.000Z","dependencies_parsed_at":"2025-02-15T18:32:27.661Z","dependency_job_id":"9bc96704-c303-4bd2-9f84-6942aa18d50c","html_url":"https://github.com/sunaoka/push-notifications-php","commit_stats":{"total_commits":35,"total_committers":1,"mean_commits":35.0,"dds":0.0,"last_synced_commit":"4f79b9b6ec08437376eba56e9049b18158d7b795"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/sunaoka/push-notifications-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunaoka%2Fpush-notifications-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunaoka%2Fpush-notifications-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunaoka%2Fpush-notifications-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunaoka%2Fpush-notifications-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunaoka","download_url":"https://codeload.github.com/sunaoka/push-notifications-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunaoka%2Fpush-notifications-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29567616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T00:47:08.760Z","status":"online","status_checked_at":"2026-02-18T02:00:09.468Z","response_time":162,"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":["apns","apple-push-notifications","fcm","firebase-cloud-messaging","notifications","php","php55","php56","php70","php71","php72","php73","php74","php80","php81","push","push-notifications"],"created_at":"2024-09-24T19:59:20.018Z","updated_at":"2026-02-18T04:01:00.380Z","avatar_url":"https://github.com/sunaoka.png","language":"PHP","readme":"# Push notifications Library for PHP\n\n[![Latest](https://poser.pugx.org/sunaoka/push-notifications-php/v)](https://packagist.org/packages/sunaoka/push-notifications-php)\n[![License](https://poser.pugx.org/sunaoka/push-notifications-php/license)](https://packagist.org/packages/sunaoka/push-notifications-php)\n[![PHP](https://img.shields.io/packagist/php-v/sunaoka/push-notifications-php)](composer.json)\n[![Test](https://github.com/sunaoka/push-notifications-php/actions/workflows/test.yml/badge.svg)](https://github.com/sunaoka/push-notifications-php/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/sunaoka/push-notifications-php/branch/develop/graph/badge.svg)](https://codecov.io/gh/sunaoka/push-notifications-php)\n\n---\n\n## Supported Protocols\n\n| Protocol                   | Supported | Driver             | Options                   |\n| -------------------------- | :-------: | ------------------ | ------------------------- |\n| APNs ([Token Based])       |  \u0026check;  | `APNs\\Token`       | `APNs\\Token\\Option`       |\n| APNs ([Certificate Based]) |  \u0026check;  | `APNs\\Certificate` | `APNs\\Certificate\\Option` |\n| APNs ([Binary Provider])   |           |                    |                           |\n| FCM ([HTTP v1])            |  \u0026check;  | `FCM\\V1`           | `FCM\\V1\\Option`           |\n| FCM ([Legacy JSON])        |           |                    |                           |\n| FCM ([Legacy Plain Text])  |           |                    |                           |\n| FCM ([XMPP])               |           |                    |                           |\n\n## Installation\n\n```bash\ncomposer require sunaoka/push-notifications-php\n```\n\n## Basic Usage\n\nFor example, in the case of APNs [Token Based].\n\n```php\n\u003c?php\n\nuse Sunaoka\\PushNotifications\\Drivers\\APNs;\nuse Sunaoka\\PushNotifications\\Pusher;\n\n$payload = [\n    'aps' =\u003e [\n        'alert' =\u003e [\n            'title' =\u003e 'Game Request',\n            'body'  =\u003e 'Bob wants to play poker',\n        ],\n    ],\n];\n\n$options = new APNs\\Token\\Option();\n$options-\u003epayload = $payload;\n$options-\u003eauthKey = '/path/to/key.p8';\n$options-\u003ekeyId = 'ABCDE12345';\n$options-\u003eteamId = 'ABCDE12345';\n$options-\u003etopic = 'com.example.app';\n\n$driver = new APNs\\Token($options);\n\n$pusher = new Pusher();\n$feedback = $pusher-\u003eto('Device token')-\u003esend($driver);\n\n$result = $feedback-\u003eisSuccess('Device token');\nif (! $result) {\n    echo $feedback-\u003efailure('Device token');\n    // BadDeviceToken\n}\n```\n\n## How to specify options\n\nThere are two ways to specify the option.\n\n```php\n$options = new APNs\\Token\\Option();\n$options-\u003epayload = $payload;\n$options-\u003eauthKey = '/path/to/key.p8';\n$options-\u003ekeyId = 'ABCDE12345';\n$options-\u003eteamId = 'ABCDE12345';\n$options-\u003etopic = 'com.example.app';\n```\n\nor\n\n```php\n$options = new APNs\\Token\\Option([\n    'payload' =\u003e $payload,\n    'authKey' =\u003e '/path/to/key.p8',\n    'keyId'   =\u003e 'ABCDE12345',\n    'teamId'  =\u003e 'ABCDE12345',\n    'topic'   =\u003e 'com.example.app',\n]);\n```\n\n## Multicast message\n\nSpecify an array of device tokens in `Pusher::to()`.\nThen, you can distribute to multiple devices.\n\n```php\n$pusher = new Pusher();\n$feedback = $pusher-\u003eto([\n    'Device token 1',\n    'Device token 2',\n    'Device token 3',\n])-\u003esend($driver);\n```\n\n## How to switch between the production and development environments (only APNs)\n\nThis is specified as an argument when creating an instance of `Pusher`.\n\n```php\n// Development environment (default)\n$pusher = new Pusher(false);\n```\n\n```php\n// Production environment\n$pusher = new Pusher(true);\n```\n\n## Feedback\n\nThe return value of `Pusher::send()` is a `Feedback` object.\n\nWith the `Feedback` object, you can determine whether the notification succeeded or failed.\n\n```php\n$pusher = new Pusher();\n$feedback = $pusher-\u003eto('Device token')-\u003esend($driver);\n\n$result = $feedback-\u003eisSuccess('Device token');\nif ($result) {\n    echo $feedback-\u003esuccess('Device token');\n    // 01234567-0123-0123-0123-01234567890A\n} else {\n    echo $feedback-\u003efailure('Device token');\n    // BadDeviceToken\n}\n```\n\n## HTTP Request Option\n\nYou can specify [Guzzle Request Options] as a driver option.\n\n```php\n$options = new APNs\\Token\\Option();\n$options-\u003ehttpOptions = [\n    'connect_timeout' =\u003e 3.14\n    'timeout'         =\u003e 3.14,\n    'debug'           =\u003e true,\n];\n```\n\n## More examples\n\nMore examples can be found in the [examples](example) directory.\n\n\n[Token Based]: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns\n[Certificate Based]: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns\n[Binary Provider]: https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/BinaryProviderAPI.html\n[HTTP v1]: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send\n[Legacy JSON]: https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json\n[Legacy Plain Text]: https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-plain-text\n[XMPP]: https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref\n[Guzzle Request Options]: https://docs.guzzlephp.org/en/stable/request-options.html\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunaoka%2Fpush-notifications-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunaoka%2Fpush-notifications-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunaoka%2Fpush-notifications-php/lists"}