Step 1. Process push notification payload and grab Call object
To present an incoming call screen, firstly you will need a Call object. You can grab this from the push notification payload itself of incoming call notification. You need to call CometChat.processMessage() method to process push notification payload.
Copy
Ask AI
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { if let userInfo = response.notification.request.content.userInfo as? [String : Any], let messageObject = userInfo["message"] as? [String:Any] { print("didReceive: \(userInfo)") if let baseMessage = CometChat.processMessage(messageObject).0 { switch baseMessage.messageCategory { case .message: print("Message Object Received: \(String(describing: (baseMessage as? TextMessage)?.stringValue()))") case .action: break case .call: break case .custom: break @unknown default: break } } } completionHandler() }
You can launch the call screen from your base view controller instead of launching it from the App Delegate. This method uses NotificationCenter to trigger and present Call Screen.
In this method you need to fire notification after you receive Call Object.
In Notification’s user info you can pass Call Object to that desired notification.