How to present a view in didReceiveRemoteNotification?

48 views Asked by At

I want to present a view when receiving a silent push notification and pass this push data.

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                 fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
{
    printLog("Did Receive Remote Notification")
    printLog(userInfo)
    do {
        let jsonResult = try JSONSerialization.data(withJSONObject: userInfo)
        let push = try JSONDecoder().decode(RequestPushModel.self, from: jsonResult)
        
        let single = RequestBearerCustomer(type: "\(push.type)", transport_id: "\(push.transport_id)", shortened_origin_address: "\(push.shortened_origin_address)", origin_lat: "\(push.origin_lat)", origin_lng: "\(push.origin_lng)", time: "\(push.time)", price: "\(push.price)", expire_time: "\(push.expire_time)")
        if Constants.requestBearerCustomer.count > 0 {
            Constants.requestBearerCustomer.insert(single, at: Constants.requestBearerCustomer.count - 1)
        } else {
            Constants.requestBearerCustomer.insert(single, at: 0)
        }
        printLog(single)
        printLog(Constants.requestBearerCustomer[0])
    } catch {
        printLog(error)
    }
0

There are 0 answers