Last active
April 23, 2018 11:43
-
-
Save alexruperez/04af582fb57c7d1306214238d4ce8ad3 to your computer and use it in GitHub Desktop.
Silent Remote Notifications
This file contains hidden or 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
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) | |
} |
This file contains hidden or 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
<key>UIBackgroundModes</key> | |
<array> | |
<string>remote-notification</string> | |
</array> |
This file contains hidden or 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
<key>aps-environment</key> | |
<string>development</string> |
This file contains hidden or 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
{ | |
"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