{"id":22726430,"url":"https://github.com/mono0926/apns","last_synced_at":"2025-07-30T21:18:59.602Z","repository":{"id":63918724,"uuid":"99565618","full_name":"mono0926/apns","owner":"mono0926","description":"APNs(Apple Push Notification Service) SDK","archived":false,"fork":false,"pushed_at":"2024-11-02T11:30:21.000Z","size":21,"stargazers_count":28,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T20:46:40.948Z","etag":null,"topics":["apns","apns-http","apns-http2","apns-sender","apns2","codable","macos","notification","notification-service","notifications","push-notifications","remote-notifications","swift4","swiftpm"],"latest_commit_sha":null,"homepage":"https://medium.com/swift-column/apns-fbd547c5919","language":"Swift","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/mono0926.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":"2017-08-07T10:19:45.000Z","updated_at":"2025-01-26T05:53:20.000Z","dependencies_parsed_at":"2023-01-14T14:00:24.948Z","dependency_job_id":null,"html_url":"https://github.com/mono0926/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/mono0926%2Fapns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono0926%2Fapns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono0926%2Fapns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mono0926%2Fapns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mono0926","download_url":"https://codeload.github.com/mono0926/apns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782279,"owners_count":21160716,"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","apns-http","apns-http2","apns-sender","apns2","codable","macos","notification","notification-service","notifications","push-notifications","remote-notifications","swift4","swiftpm"],"created_at":"2024-12-10T16:17:18.148Z","updated_at":"2025-04-13T20:46:50.481Z","avatar_url":"https://github.com/mono0926.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APNS \n\n## `APNS` initialization\n\nThere are two ways to initialize `APNS` instance.\n\n- By code.\n- Locate [Config.plist](https://github.com/mono0926/apns/blob/master/Config.plist).\n\n## Example\n\n```swift\nclass APNSTests: XCTestCase {\n    var target: APNS!\n    private let deviceToken: DeviceToken = \"0c34a62170c1c0be603780e6458b20dc902730094805b87bef896e6f5ed9bbcb\"\n\n    func testSend_Code() throws {\n        // Initialize from the config file\n        target = try APNS(configPath: \"/Users/mono/Documents/Config.plist\")\n\n        // Or from each argument\n//        target = try APNS(keyPath: \"YOUR_p8_KEY_PATH\",\n//                          keyId: \"YOUR_KEY_ID\",\n//                          teamId: \"YOUR_TEAM_ID\",\n//                          environment: .sandbox, .production or .all) // environmentは省略可能\n\n        // All fields can be omitted\n        let alert = Alert(title: \"title\",\n                          subtitle: \"subtitle\",\n                          body: \"body\",\n                          titleLocalizationKey: nil,\n                          titleLocalizationArguments: nil,\n                          actionLocalizationKey: nil,\n                          bodyLocalizationKey: nil,\n                          bodyLocalizationArguments: nil,\n                          launchImage: nil)\n        let aps = Aps(alert: alert,\n                      badge: nil, // Can be omitted below\n                      sound: \"Default\",\n                      contentAvailable: nil,\n                      category: nil,\n                      threadId: nil)\n        let payload = Payload(aps: aps,\n                              custom: Custom(test: \"custom-value\")) //  Can be omitted\n        let request = APNSRequest(topic: \"com.mono0926.notification.example\",\n                                  payload: payload,\n                                  apnsIdentifier: UUID(), // Can be omitted below\n                                  priority: .immediately,\n                                  expiration: Date().addingTimeInterval(3600),\n                                  collapseIdentifier: \"collapse-identifier\")\n        \n        let results = try target.send(request: request,\n                        deviceTokens: [deviceToken])\n        results.forEach { print($0) }\n    }\n\n    func testSend_JSON() throws {\n        target = try APNS(configPath: \"/Users/mono/Documents/Config.plist\")\n\n        let payload = Payload(aps: try Aps(jsonPath: \"/Users/mono/Documents/aps.json\"),\n                              custom: try Custom(jsonPath: \"/Users/mono/Documents/custom.json\"))\n\n        let request = APNSRequest(topic: \"com.mono0926.notification.example\",\n                                  payload: payload)\n\n        let results = try target.send(request: request,\n                                      deviceTokens: [deviceToken])\n        results.forEach { print($0) }\n    }\n}\n\nstruct Custom: Codable, CustomPayload {\n    let test: String\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmono0926%2Fapns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmono0926%2Fapns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmono0926%2Fapns/lists"}