{"id":18550030,"url":"https://github.com/huxia/apns2","last_synced_at":"2025-09-07T06:35:46.588Z","repository":{"id":56962653,"uuid":"87282647","full_name":"huxia/apns2","owner":"huxia","description":"Simple \u0026 expressive HTTP2 API for Apple Push Notification service (APNs) with comprehensive docs/constants.","archived":false,"fork":false,"pushed_at":"2017-07-06T08:21:51.000Z","size":28,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-07T06:35:10.786Z","etag":null,"topics":["apns","apns2","composer","http2","http2-push","notifications","php","push"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huxia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-05T07:58:56.000Z","updated_at":"2024-10-21T05:17:35.000Z","dependencies_parsed_at":"2022-08-21T10:20:47.447Z","dependency_job_id":null,"html_url":"https://github.com/huxia/apns2","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/huxia/apns2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxia%2Fapns2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxia%2Fapns2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxia%2Fapns2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxia%2Fapns2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huxia","download_url":"https://codeload.github.com/huxia/apns2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huxia%2Fapns2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274005333,"owners_count":25205934,"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-07T02:00:09.463Z","response_time":67,"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","apns2","composer","http2","http2-push","notifications","php","push"],"created_at":"2024-11-06T21:03:22.068Z","updated_at":"2025-09-07T06:35:46.538Z","avatar_url":"https://github.com/huxia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apns2\n\nSimple \u0026 expressive PHP HTTP2 API for Apple Push Notification service (APNs) with comprehensive docs/constants.\n\n### Guidance\n\n1. [Make Sure CURL Supports HTTP/2](http://stackoverflow.com/a/34831873/286348) (for php version \u003c 5.5.24, check [here](https://stackoverflow.com/a/34609756))\n2. [Creating a Universal Push Notification Client SSL Certificate (.p12)](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW11)\n3. Converting .p12 to .pem\n\u003e `openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts`\n4. Go\n\u003e `composer require dashi/apns2`\n\n\n### Usage\n\n#### using classes\n\n```php\n$connection = new Dashi\\Apns2\\Connection();\n$connection-\u003esandbox = false;\n$connection-\u003ecertPath = '/path/to/http2/cert.pem';\n\n$aps = new Dashi\\Apns2\\MessageAPSBody();\n$aps-\u003ealert = 'test 1';\n$aps-\u003esound = 'default';\n\n$message = new Dashi\\Apns2\\Message();\n$message-\u003eaps = $aps;\n\n$options = new Dashi\\Apns2\\Options();\n$options-\u003eapnsTopic = 'your.bundle.id';\n\n$responses = $connection-\u003esend([\n    '81fbf7e296f6c94755832a48476182e4e9586a380116e18a46531b62349504f0',\n    'e2d0b464813b6b2371d745dff2b1e5fb6b83b07f7dcd98cc9f1346a7752dcc45',\n], $message, $options);\n$connection-\u003eclose();\nvar_dump($responses);\n```\n\n#### using arrays\n\n```php\n$connection = new \\Dashi\\Apns2\\Connection(['sandbox' =\u003e true, 'cert-path' =\u003e '/path/to/http2/cert.pem']);\n\n$responses = $connection-\u003esend([\n    '81fbf7e296f6c94755832a48476182e4e9586a380116e18a46531b62349504f1' // invalid\n], [\n    'aps' =\u003e [\n        'alert' =\u003e 'test 2',\n        'sound' =\u003e 'default',\n    ]\n], [\n    'apns-topic' =\u003e 'your.bundle.id',\n]);\n$connection-\u003eclose();\n```\n#### check response data\n```php\necho \"check response: {$responses[0]-\u003eapnsId} == ${uuid}\\n\";\nassert($responses[0]-\u003eapnsId == $uuid);\n\n$reason = \\Dashi\\Apns2\\Response::REASON_BAD_DEVICE_TOKEN;\necho \"check response: {$responses[0]-\u003ereason} == ${reason}\\n\";\nassert($responses[0]-\u003ereason == $reason);\n```\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuxia%2Fapns2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuxia%2Fapns2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuxia%2Fapns2/lists"}