Silent push for iOS
XCode → Signing & Capabilities → Background modes
Depends what you want to achieve with silent push, turn on Background fetch or Background processing or both.
Â
Â
At AppDelegate file you need to add those two methods to handle silent push content.
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print("perform fetch completition")
Appoxee.shared()?.performFetch(completionHandler: nil, andNotifyCompletionWith: { (error, data) in
if (NSNumber.isKind(of: data as! AnyClass)) {
print(data ?? "no date");
completionHandler(.newData)
}
completionHandler(.noData)
})
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print(userInfo)
Appoxee.shared()?.didReceiveRemoteNotification(userInfo, fetchCompletionHandler: completionHandler, andNotifyCompletionWith: { (error, data) in
if ((error) != nil) {
completionHandler(.failed)
} else {
//// No need to pefrom any action, since Appoxee will call completionHandler() providing it a UIBackgroundFetchResult.
}
})
}
Â
Â
Â