I ship APNs notifications to my units with the CloudKit dashboard. I check with two units;
System with Silent Push Working Efficiently:
iOS model 16.5.1
(c), Mannequin iPhone Xs
Silent Push Failed System:
iOS model 15.3.1
, Mannequin iPhone Xr
Regular alert notifications work efficiently on each units. However I am unable to see any log in my mission though silent push is shipped efficiently on one machine.
What I’ve Checked:
-
content-available
is ready to1
. -
My app is just not in kill state, it’s in foreground or pending within the background.
-
After I ship easy notifications, I can see logs in my swift mission and notifications on bodily units with none downside.
-
No, my certificates has not expired and if there was an issue with it, I might not have the ability to see the conventional notifications.
-
My cellphone is just not in energy saving mode and the “Background App Refresh” choice is turned on within the app’s settings.
-
Each units in charging state.
-
App capabilities: Background Modes is enabled with
Distant Notifications
,Background Fetch
,Background Processing
.
CloudKit Dashboard After Sending Silent Push:
My AppDelegate Class In Swift Challenge:
import SwiftUI
import UIKit
import UserNotifications
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func software(_ software: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.present().requestAuthorization(choices: [.alert, .sound, .badge]) { granted, error in
if granted {
DispatchQueue.major.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}
return true
}
func software(_ software: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Knowledge) {
let tokenParts = deviceToken.map { information in String(format: "%02.2hhx", information) }
let token = tokenParts.joined()
print("System Token: (token)")
}
func software(_ software: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Didn't register: (error)")
}
func software(_ software: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
logInfo("Obtained Push Notification: (userInfo)")
if let aps = userInfo["aps"] as? [String: AnyObject], aps["content-available"] as? Int == 1 {
logInfo("It is a silent push notification")
//DO SOME WORK
completionHandler(.newData)
}
completionHandler(.newData)
}
}