our app support silent push, and we use below code to get if app is launched by silent push:
if let remoteNotification = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],
let aps = remoteNotification["aps"] as? [AnyHashable: Any],
let contentAvailable = aps["content-available"] as? Int,
contentAvailable == 1 {
isSilentNotification = true
}
when app is launch and call:
application(_:didFinishLaunchingWithOptions:)
but when migrate to UIScene, the launchOptions is always nil, and we can not get to know if app is launched by silent push; I read the develop doc:
it says:
If the app supports scenes, this is nil.
Continue using UIApplicationDelegate's application(_:didReceiveRemoteNotification:fetchCompletionHandler:) to process silent remote notifications after scene connection.
but the time for method calling
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
id too late.
So except in didReceiveRemoteNotification method calling:
application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
are there any other ways to obtain the silent push flag when app is launch and has not didReceiveRemoteNotification call back.