Search code examples
iosswiftxcodeimessage

Using different views in a iMessage App through hiding and showing the views


I am coding an iMessage app at the moment. I have implemented 5 views into the messages view controller. I always want to show one and hide the other 4 depending on which state of the game I am in. I added a URL component to the message but I don't have success with changing the view hiding depending on the path of the URL I am in. For example:

base URL: "apple.com/" should show the first view
second URL: "apple.com/secondView/" should show the second view

I have the problem that there is not so much about iMessage apps out there. I want the same behaviour like GamePigeon and I am having problems with the view navigation. Has anyone experienced that and helped me out?

Big thanks!


Solution

  • I solved it via creating Segues from the MessagesViewController and calling them for the state of the different message urls.

    override func willBecomeActive(with conversation: MSConversation) {
        
        super.willBecomeActive(with: conversation)
        
       
        if let url = conversation.selectedMessage?.url {
            if(url = firstURL {
                self.performSegue(withIdentifier: "YourSegueIdentifier", sender: self)
            }
            
        }
    }