How to set up push notifications in Swift

BlakeH picture BlakeH · Jul 23, 2014 · Viewed 84.1k times · Source

I am trying to set up a push notification system for my application. I have a server and a developer license to set up the push notification service.

I am currently running my app in Swift. I would like to be able to send the notifications remotely from my server. How can I do this?

Answer

Adam Waite picture Adam Waite · Jun 27, 2015

Swift 2:

let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()