V2 chat notifications not opening to chat

Notification is received right, been trying to follow the steps here:

Code in AppDelegate:

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"], let str = messageObject as? String, let dict = str.stringTodictionary() {
          print("didReceive: \(userInfo)")
          if let baseMessage = CometChat.processMessage(dict).0 {
            print(baseMessage)
            switch baseMessage.messageCategory {
                case .message: print("Message Object Received")
                case .action: break
                case .call: break
                case .custom: break
                @unknown default: break
            }
            
            if let message = baseMessage as? BaseMessage {
                print(baseMessage);
              switch baseMessage.receiverType {
                case .user:
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                   if let user = baseMessage.sender {
                     NotificationCenter.default.post(name: NSNotification.Name(rawValue: "didReceivedMessageFromUser"), object: nil, userInfo: ["user":user])
                   }
                 }
                case .group:
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                  if let group = baseMessage.receiver as? Group {
                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "didReceivedMessageFromGroup"), object: nil, userInfo: ["group":group])
                   }
                  }
                @unknown default: break
              }
            }
          }
    }
    completionHandler()
}

The serialize JSON code exists.

My contentholderVC which functions as my ‘basecontroller’:

class ContentHolderVC: UIViewController {

var menuIconIsActive:Bool = true

@IBOutlet weak var menuOrBackIcon: UIImageView!

@IBOutlet weak var navigationBarLogo: UIImageView!

//MARK: - Initialization

override func viewDidLoad() {

super.viewDidLoad()

AppNotify.observeNotification(self, selector: #selector(setMenuIcon), name: MLNotification.MenuIcon)

AppNotify.observeNotification(self, selector: #selector(setBackIcon), name: MLNotification.BackIcon)

AppNotify.observeNotification(self, selector: #selector(setNavigationAppLogo), name: MLNotification.NavigationAppLogo)

AppNotify.observeNotification(self, selector: #selector(setNavigationClubLogo), name: MLNotification.NavigationClubLogo)

NotificationCenter.default.addObserver(self, selector:#selector(self.didReceivedMessageFromGroup(_:)), name: NSNotification.Name(rawValue: “didReceivedMessageFromGroup”), object: nil)

NotificationCenter.default.addObserver(self, selector:#selector(self.didReceivedMessageFromUser(_:)), name: NSNotification.Name(rawValue: “didReceivedMessageFromUser”), object: nil)

// Do any additional setup after loading the view.

self.oneSignalPush()

MySingleton.getUserID()

MySingleton.requestUserInformations()

}

And the last bit of code it mentions, also in ContentHolderVC:

@objc func didReceivedMessageFromGroup(_ notification: NSNotification) {
        if let group = notification.userInfo?["group"] as? Group {
            DispatchQueue.main.async {
             let messageList = CometChatMessageList()
             let navigationController = UINavigationController(rootViewController:messageList)
              messageList.set(conversationWith: group, type: .group)
              self.present(navigationController, animated:true, completion:nil)
            }
        }
    }
    
    @objc func didReceivedMessageFromUser(_ notification: NSNotification) {
          print("didReceivedMessageFromUser")
        if let user = notification.userInfo?["user"] as? User {
            DispatchQueue.main.async {
             let messageList = CometChatMessageList()
             let navigationController = UINavigationController(rootViewController:messageList)
              messageList.set(conversationWith: user, type: .user)
              self.present(navigationController, animated:true, completion:nil)
            }
        }
    }

It looks like I’ve followed the instructions, but it still won’t open to the chat – it just opens the app.

Also, here’s our methods in our internal navigation controller:

//MARK: - Navigation Methods
@objc func openCometChatUserMessageList(notification:Notification) {
    print("here");

    let messageList = CometChatMessageList()
    guard let user = notification.userInfo?["user"] as? User else { return }

// let navigationController = UINavigationController(rootViewController:messageList)
messageList.set(conversationWith: user, type: .user)

    //new change here
    if mySingleton.openedPageId == nil || mySingleton.lastOpenedPageId == nil {
        mySingleton.openedPageId = "cometChatMessageList"
        mySingleton.lastOpenedPageId = mySingleton.openedPageId
    } else {
        mySingleton.lastOpenedPageId = mySingleton.openedPageId
        mySingleton.openedPageId = "cometChatMessageList"
    }
    
    if !mySingleton.pageIds.contains("cometChatMessageList") //if it doesnt containe then show back icon
    {
        AppNotify.postNotification(MLNotification.BackIcon)
    }
    else
    {
        AppNotify.postNotification(MLNotification.MenuIcon)
    }
    
    self.pushViewController(messageList, animated: true)
    if !self.viewControllers.contains(messageList) {
        self.viewControllers = [messageList]
    }
}

@objc func openCometChatGroupMessageList(notification:Notification) {
    let messageList = CometChatMessageList()
    guard let user = notification.userInfo?["group"] as? Group else { return }

// let navigationController = UINavigationController(rootViewController:messageList)
messageList.set(conversationWith: user, type: .group)

    //new change here
    if mySingleton.openedPageId == nil || mySingleton.lastOpenedPageId == nil {
        mySingleton.openedPageId = "cometChatMessageList"
        mySingleton.lastOpenedPageId = mySingleton.openedPageId
    } else {
        mySingleton.lastOpenedPageId = mySingleton.openedPageId
        mySingleton.openedPageId = "cometChatMessageList"
    }
    
    if !mySingleton.pageIds.contains("cometChatMessageList") //if it doesnt containe then show back icon
    {
        AppNotify.postNotification(MLNotification.BackIcon)
    }
    else
    {
        AppNotify.postNotification(MLNotification.MenuIcon)
    }
    
    self.pushViewController(messageList, animated: true)
    if !self.viewControllers.contains(messageList) {
        self.viewControllers = [messageList]
    }
}