An iMessage app lives inside the Messages app, just like you would expect from an extension. As mentioned before, iMessage apps are a special kind of extension, which makes them behave a lot like apps at times even though they are still extensions at their core.
The main view controller for an iMessage app must always be a subclass of MSMessagesAppViewController. You can't have a primary view controller that is not a subclass of this class. When the user navigates to your extension through the iMessage apps drawer, this view controller is added in the compact mode. You've already seen this mode in action when you created your sticker pack.
When the Messages framework instantiates your extension, the willBecomeActive(with:) method is called, followed by didBecomeActive(with:). These messages are called after viewDidLoad in the view controller life cycle, but before viewWillAppear. When it's time to dismiss your extension, the viewWillDisappear and viewDidDisappear life cycle methods are called. Next, willResignActive(with:) and didResignActive(with:) are called.
Once the resignation methods are called, the process for your iMessage app is killed shortly thereafter. You do not get any time to do work in the background, just like with other extensions. Again, even though Messages extensions behave a lot like apps, they're not.
There are two more methods you should know about for now. These methods are called whenever we're transitioning from one display mode to another. The display mode is changed whenever the user taps the upward chevron in the bottom right part of the iMessage interface. Take a look at the following screenshot:
You can also trigger this transition from your code by calling requestPresentationStyle(_:). The delegate methods that get called are willTransition(to:) and didTransition(to:). The first is called right before the transition occurs, the second is called right after. This just like their names suggest.