Skip to content

Instantly share code, notes, and snippets.

@alexruperez
Last active April 23, 2018 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexruperez/04af582fb57c7d1306214238d4ce8ad3 to your computer and use it in GitHub Desktop.
Save alexruperez/04af582fb57c7d1306214238d4ce8ad3 to your computer and use it in GitHub Desktop.
Silent Remote Notifications
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if !application.isRegisteredForRemoteNotifications {
application.registerForRemoteNotifications()
}
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print(deviceToken.reduce("", {$0 + String(format: "%02X", $1)}))
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
completionHandler(.noData)
}
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>aps-environment</key>
<string>development</string>
{
"aps" : {
"content-available" : 1
},
"foo" : "bar",
"acme" : 42
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment