{"id":1683,"url":"https://github.com/pisces/APNSUtil","last_synced_at":"2025-08-02T04:32:19.000Z","repository":{"id":56900913,"uuid":"125303194","full_name":"pisces/APNSUtil","owner":"pisces","description":"APNSUtil is makes code simple using apple push notification service","archived":false,"fork":false,"pushed_at":"2019-12-02T06:09:38.000Z","size":306,"stargazers_count":32,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-23T19:17:50.669Z","etag":null,"topics":["apns","applie","remotenotification","swift","utils"],"latest_commit_sha":null,"homepage":"","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/pisces.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":"2018-03-15T02:46:10.000Z","updated_at":"2023-12-20T04:06:37.000Z","dependencies_parsed_at":"2022-08-20T18:20:33.867Z","dependency_job_id":null,"html_url":"https://github.com/pisces/APNSUtil","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/pisces/APNSUtil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pisces%2FAPNSUtil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pisces%2FAPNSUtil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pisces%2FAPNSUtil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pisces%2FAPNSUtil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pisces","download_url":"https://codeload.github.com/pisces/APNSUtil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pisces%2FAPNSUtil/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334615,"owners_count":24233793,"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-08-02T02:00:12.353Z","response_time":74,"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","applie","remotenotification","swift","utils"],"created_at":"2024-01-05T20:15:53.233Z","updated_at":"2025-08-02T04:32:18.722Z","avatar_url":"https://github.com/pisces.png","language":"Swift","funding_links":[],"categories":["Notifications"],"sub_categories":["Push Notifications","Other free courses"],"readme":"# APNSUtil\n\n![Swift](https://img.shields.io/badge/Swift-5-orange.svg)\n[![CI Status](http://img.shields.io/travis/pisces/APNSUtil.svg?style=flat)](https://travis-ci.org/pisces/APNSUtil)\n[![Version](https://img.shields.io/cocoapods/v/APNSUtil.svg?style=flat)](http://cocoapods.org/pods/APNSUtil)\n[![License](https://img.shields.io/cocoapods/l/APNSUtil.svg?style=flat)](http://cocoapods.org/pods/APNSUtil)\n[![Platform](https://img.shields.io/cocoapods/p/APNSUtil.svg?style=flat)](http://cocoapods.org/pods/APNSUtil)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n- APNSUtil makes code simple settings and landing for apple push notification service.\n\n## Features\n- Using apple push notification service simply\n- No need write codes for any iOS versions\n- Support chained functional programing\n\n## Import\n\n```swift\nimport APNSUtil\n```\n\n## Using\n\n### Implementation for main view controller\n```swift\nimport UIKit\nimport APNSUtil\n\nclass ViewController: UIViewController {\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        APNSManager.shared\n            .setTypes([.sound, .alert, .badge])             // setting user notification types\n            .register()                                     // register to use apns\n            .subscribe(self) {                             // subscribe to receive apns payload\n                // your payload model with generic\n                guard let payload: APNSPayload = $0.payload() else {\n                    return\n                }\n\n                print(\"subscribe\", $0.isInactive, $0.userInfo, payload)\n\n                if $0.isInactive {\n                    // TODO: write code to present viewController on inactive\n                } else {\n                    // TODO: write code to show toast message on active\n                }\n            }.begin()   // begin to receive apns payload\n    }\n}\n```\n\n### Implementation for app delegate\n\n```swift\nimport UIKit\nimport UserNotifications\nimport APNSUtil\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n    var window: UIWindow?\n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n        APNSManager.shared.application(application, didFinishLaunchingWithOptions: launchOptions)\n        return true\n    }\n\n    // MARK: - Push Notification\n\n    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\n        APNSManager.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\n        // \u003c\u003cyour function to register device token on your server\u003e\u003e(APNSInstance.shared.tokenString)\n    }\n    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\n    }\n\n    // MARK: - Push Notification for iOS 9\n\n    func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) {\n        APNSManager.shared.application(application, didRegister: notificationSettings)\n    }\n    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {\n        APNSManager.shared.application(application, didReceiveRemoteNotification: userInfo)\n    }\n\n    // MARK: - Public Methods (UIApplicationDelegate - Local Notification)\n\n    func application(_ application: UIApplication, didReceive notification: UILocalNotification) {\n        APNSManager.shared.application(application, didReceive: notification)\n    }\n}\n\nextension AppDelegate: UNUserNotificationCenterDelegate {\n    @available(iOS 10.0, *)\n    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -\u003e Void) {\n        APNSManager.shared.userNotificationCenter(center, willPresent: notification)\n    }\n    @available(iOS 10.0, *)\n    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -\u003e Void) {\n        APNSManager.shared.userNotificationCenter(center, didReceive: response)\n    }\n}\n```\n\n### Implement your payload model\n```swift\nstruct APNSPayload: Decodable {\n    let aps: APS?\n\n    // Add properties here you need\n\n    struct APS: Decodable {\n        let sound: String?\n        let alert: Alert?\n    }\n\n    struct Alert: Decodable {\n        let body: String?\n        let title: String?\n    }\n}\n```\n\n### Using with your payload model as generic\n\n```swift\n  APNSManager.shared\n      .setTypes([.sound, .alert, .badge])\n      .register()\n      .subscribe(self) {\n          guard let payload: APNSPayload = $0.payload() else {\n              return\n          }\n\n          // write here to process payload model\n      }.begin()\n```\n\n### Using with raw userInfo\n\n```swift\n  APNSManager.shared\n      .setTypes([.sound, .alert, .badge])\n      .register()\n      .subscribe(self) {\n          let userInfo = $0.userInfo\n\n          // write here to process userInfo\n      }.begin()\n```\n\n## Installation\n\n### 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\n\u003e CocoaPods 1.0.0+ is required to build APNSUtil 1.1.5+.\n\nTo integrate APNSUtil 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'\n\n# Default\ntarget '\u003cYour Target Name\u003e' do\n    pod 'APNSUtil', '~\u003e 1.6.0'\nend\n\n# for AppExtension\ntarget '\u003cYour Target Name\u003e' do\n    pod 'APNSUtil/AppExtension', '~\u003e 1.6.0'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### 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 update\n$ brew install carthage\n```\n\nTo integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"pisces/APNSUtil\" ~\u003e 1.6.0\n```\n\nRun `carthage update` to build the framework and drag the built `APNSUtil.framework` into your Xcode project.\n\n## Requirements\n\niOS Deployment Target 9.0 higher\n\n## Author\n\nSteve Kim, hh963103@gmail.com\n\n## License\n\nAPNSUtil is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpisces%2FAPNSUtil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpisces%2FAPNSUtil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpisces%2FAPNSUtil/lists"}