Last active
October 19, 2015 19:47
-
-
Save suparngp/1109c80e2e90a2f48432 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PushKit | |
import AdSupport | |
import Foundation | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var voipRegistry:PKPushRegistry! | |
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
//register for notifications | |
registerVoipNotifications() | |
return true | |
} | |
//PushKit functions | |
func registerVoipNotifications() { | |
let types:UIUserNotificationType = [UIUserNotificationType.Badge, UIUserNotificationType.Sound] | |
let notificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil) | |
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings) | |
} | |
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) { | |
voipRegistry = PKPushRegistry(queue: dispatch_get_main_queue()) | |
voipRegistry.delegate = self | |
voipRegistry.desiredPushTypes = Set([PKPushTypeVoIP]) | |
Logger.debug("VOIP Push registered") | |
} | |
} | |
extension AppDelegate: PKPushRegistryDelegate{ | |
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) { | |
let pushToken: String! = credentials.token.description | |
Logger.debug("\n\n##### PushKit credential: %@\n\n", pushToken) | |
} | |
func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) { | |
let data = payload.dictionaryPayload | |
Logger.debug("\n\n##### Received PushKit Data: %@ \n\n", data) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Logger.debug just wraps the NSLog.