{"id":19686590,"url":"https://github.com/alexeyxo/swift-apns","last_synced_at":"2025-04-29T06:31:28.893Z","repository":{"id":56900915,"uuid":"50602072","full_name":"alexeyxo/swift-apns","owner":"alexeyxo","description":"Swift Framework for sending Apple Push Notification over HTTP/2 API","archived":false,"fork":false,"pushed_at":"2017-01-07T12:19:10.000Z","size":218,"stargazers_count":155,"open_issues_count":5,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-14T06:37:48.780Z","etag":null,"topics":["apns","protocol-buffers","push","push-notifications","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexeyxo.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":"2016-01-28T17:58:27.000Z","updated_at":"2025-03-07T11:35:03.000Z","dependencies_parsed_at":"2022-11-29T13:20:29.844Z","dependency_job_id":null,"html_url":"https://github.com/alexeyxo/swift-apns","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeyxo%2Fswift-apns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeyxo%2Fswift-apns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeyxo%2Fswift-apns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexeyxo%2Fswift-apns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexeyxo","download_url":"https://codeload.github.com/alexeyxo/swift-apns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251450656,"owners_count":21591407,"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","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","protocol-buffers","push","push-notifications","swift"],"created_at":"2024-11-11T18:29:20.202Z","updated_at":"2025-04-29T06:31:28.282Z","avatar_url":"https://github.com/alexeyxo.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"\"\u003e\n    \u003cimg alt=\"Logo\" src=\"https://raw.githubusercontent.com/alexeyxo/swift-apns/master/logo.png\" width=\"500px\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n   Simple framework for sending Apple Push Notifications.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\n  \u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\u003cimg alt=\"Carthage compatible\" src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"http://cocoapods.org/?q=APNS\"\u003e\u003cimg alt=\"Version\" src=\"http://img.shields.io/cocoapods/v/APNS.svg\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"http://cocoapods.org/?q=APNS\"\u003e\u003cimg alt=\"Platform\" src=\"http://img.shields.io/cocoapods/p/APNS.svg\"\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Installation](#installation)\n  - [CocoaPods](#-cocoapods)\n  - [Carthage](#-carthage)\n- [Usage](#usage)\n  - [Simple Example](#simple-example)\n  - [Using with \"Protocol Buffers\"](#using-with-protocol-buffers)\n    - [Simple Example](#simple-example-1)\n    - [Sending Custom Objects](#sending-custom-objects)\n- [Credits](#credits)\n\n## Installation\n\n### \u003cimg src=\"https://avatars3.githubusercontent.com/u/1189714\" width=\"22\" height=\"22\"\u003e CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate *swift-apns* into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '9.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'APNS', '~\u003e 1.0'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### \u003cimg src=\"https://cloud.githubusercontent.com/assets/432536/5252404/443d64f4-7952-11e4-9d26-fc5cc664cb61.png\" width=\"22\" height=\"22\"\u003e Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew install carthage\n```\n\nTo integrate *swift-apns* into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"alexeyxo/swift-apns\"\n```\n\nRun `carthage update` to build the framework and drag the built `.framework` file into your Xcode project.\n\n\n## Usage\n\n### Simple Example\n\n```swift\nlet aps = [\"sound\":\"default\", \"alert\":\"testPush()\"]\nlet payload = [\"aps\":aps]\n_ = try! APNSNetwork().sendPush(topic: \"com.asdasd.asdasdas\", priority: 10, payload: payload, deviceToken: \"3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe\", certificatePath: Bundle(for:UnitTest.self).pathForResource(\"push\", ofType: \"p12\")!, passphrase: \"123456\", sandbox: true, responseBlock: { (response) in\n        XCTAssertTrue(response.serviceStatus.0 == 200)\n        self.expectation.fulfill()\n    }, networkError: { (error) in\n        \n})\n```\n\n```swift\n        \n        let aps = [\"sound\":\"default\", \"alert\":\"testPush()\"]\n        let payload = [\"aps\":aps]\n        let str = Bundle(for:UnitTest.self).pathForResource(\"cert\", ofType: \"p12\")!\n        var mess = ApplePushMessage(topic: \"com.tests.asdasdasd\",\n                             priority: 10,\n                             payload: payload,\n                             deviceToken: \"3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe\",\n                             certificatePath:str,\n                             passphrase: \"123456\",\n                             sandbox: true,\n                             responseBlock:nil,\n                             networkError:nil, session: nil)\n        \n        mess.responseBlock = { response in\n        }\n        \n        mess.networkError = { err in\n            if (err != nil) {\n\n            }\n        }\n        _ = try! mess.send() // OR try! mess.send(session:\u003cURLSession\u003e) \n        \n\n```\n\n### Using with \"Protocol Buffers\"\n\n\u003e Required Protocol Buffers 3.0 and [protobuf-swift](https://github.com/alexeyxo/protobuf-swift).\n\n#### Simple Example\n```swift\nlet providerData = Apple.Apns.ProviderData.Builder()\nproviderData.bundle = \"com.aasdad.asdasdsdfa\"\nproviderData.serviceIdentity = Apple.Apns.ProviderData.Identity.Development\nproviderData.priority = 10\nproviderData.certificatePath = NSBundle(forClass:UnitTest.self).pathForResource(\"push\", ofType: \"p12\")!\nproviderData.certificatePassphrase = \"123456\"\nproviderData.token = \"3dd55a59056441ab275b8b679458388cae76be3a9a02a00234388e50fe91f2fe\"\n\nlet aps = Apple.Apns.Push.Aps.Builder()\naps.badge = 1\naps.contentAvailable = 1\naps.sound = \"default\"\naps.alert = \"testSendProtobuf()\"\ndo {\n    let payload = try Apple.Apns.Push.Builder().setAps(aps.build()).build()\n    providerData.payload = payload\n    try APNSNetwork().sendPush(providerData.build(), responseBlock: { (response) -\u003e () in\n        print(response)\n    })\n} catch {\n\n}\n```\n\n#### Sending Custom Objects\n\n1. Edit ./Source/ProtoSource/PushService.proto:\n  ```protobuf\n  ...\n  message Push {\n      message Aps {\n          string alert = 1;\n          string sound = 2;\n          int32 badge = 3;\n          int32 content_available = 4;\n          string category = 5;\n      }\n\n      message ExampleCustomObject {\n          string objectId = 1;\n      }\n\n    Aps aps = 1;\n      ExampleCustomObject customObject = 2;\n  }\n  ```\n\n2. Compile new object:\n  ```bash\n  protoc PushService.proto --swift_out=\"../\"\n  ```\n\n## Credits\n\n- The bird used in the logo - as well as the cloud - are borrowed respectively\nfrom the original *Swift* and *APNs* logos which have\n*All Rights Reserved to Apple Inc.\n\n- The font used in logo comes from the [San Francisco family](https://developer.apple.com/fonts/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexeyxo%2Fswift-apns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexeyxo%2Fswift-apns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexeyxo%2Fswift-apns/lists"}