Latest 0.1.0
License MIT
Platforms ios 8.0
Frameworks UIKit



  • [x] Register your app for push notifications
  • [x] Subcribe your UIViewController(s) for new push notifications


  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.


PushNotificationHandler is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "PushNotificationHandler"

Then, run the following command:

$ pod install


Registering your app for push notifications

In your AppDelegate.swift file

import PushNotificationHandler
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    PushNotificationHandler.sharedInstance.handleApplicationStartWith(application, launchOptions: launchOptions)

    PushNotificationHandler.sharedInstance.registerNewAPNSTokenHandler { (tokenData, token, error) -> (Void) in
        if let validToken = token {
            print("Device Token:", validToken)
        } else {
            print("Device token error: " + (error?.description ?? "Strange things are happening"))

Also implement the methods as following

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    PushNotificationHandler.sharedInstance.application(application, didReceiveRemoteNotification: userInfo)
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
    PushNotificationHandler.sharedInstance.application(application, didRegisterUserNotificationSettings: notificationSettings)
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    PushNotificationHandler.sharedInstance.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    PushNotificationHandler.sharedInstance.application(application, didFailToRegisterForRemoteNotificationsWithError: error)

Subscribe a UIViewController for push notifications

In your UIViewController file

import PushNotificationHandler

Your controller must implement PushNotificationSubscriber protocol

override func viewDidLoad() {
deinit {
func newPushNotificationReceived(aps: [String : AnyObject]) {
//do something with the push notification

That’s it!


George Tsifrikas

PushNotificationHandler is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "PushNotificationHandler",
    "version": "0.1.0",
    "summary": "A simple library to register(optioanl) and handle push notifications in your app.",
    "description": "With this library you can register your app for push notifications and get the notification token without any hassle in order to send it to your Push Notification Service (your backend server for example). Also provides a subscription based model that any UIViewController can subscribe and get PushNotifications.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "George Tsifrikas": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "source_files": "PushNotificationHandler/*",
    "frameworks": "UIKit"

Pin It on Pinterest

Share This