Learn how to handle a silent notification, downloading data in the background so it's ready when your user opens your app.
This is a companion discussion topic for the original entry at https://www.kodeco.com/1258151-push-notifications/lessons/6
Learn how to handle a silent notification, downloading data in the background so it's ready when your user opens your app.
I’m working on standalone watch app. I’m using OneSingal to push silence notification, but it doesn’t work. However it work for the alert notification.
This is the setup process. Link
Hello @ehwah ! Thank you so much for adding your question in the forum.
I’ll tag some team members here so they could look into this for you. Cheers!
Hello @gdelarosa @robertomachorro cc:ing you here.
If possible, please provide more details about your setup. Xcode changes a lot. Preferably also upload your code to Github and share a link here. Your Google Drive isn’t working at my end.
Xcode
My Watch
My code
let wkExt = WKExtension.shared()
wkExt.registerForRemoteNotifications()
func didRegisterForRemoteNotifications(withDeviceToken deviceToken: Data) {
let token = deviceToken.reduce("") { $0 + String(format: "%02x", $1)}
print(token)
addDevice(token)
}
func didReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (WKBackgroundFetchResult) -> Void) {
print("did recieve remote notification", Date().description(with: .current))
completionHandler(.newData)
}
Testing on Apple Push Notification Tester Push Notifications Console
Testing on OneSignal
@Audrey please see above, thanks!
hi ehwah! this video course is from 2019, based on the first edition of the book, which has been updated three times, most recently in 2022. Have a look at section 8.3: Push Notifications by Tutorials, Chapter 8: Handling Common Scenarios | Kodeco for the Xcode 14 version. If you still have problems, ask the author @gargoyle in the Chapter 8 forum.