I have set up the silent push notification for my app: 1. I configured the push notification from all places, i.e., XCode, Apple Developer portal with proper certificate 2. I enabled background capability 3. I included "content-available" in the json payload.
However, my App can not receive silent push sometimes.
To be more specific, neither
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
......
}
nor
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (_: UIBackgroundFetchResult) -> Void) {
......
}
has been invoked when the push message arrives.
How can I get the information in the push notification in such state?
I'm waiting online.
You question is twofold: 1. why the two delegate callbacks can not be invoked 2. what should you do to receive the data.
I did some hand test and here is the result:
1, when an app is in killed state, the two callback can not be invoked indeed 2. however, when you open the app next time,
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
......
}
can be invoked and you can get the data from there.
I hope this is useful.