What is the right moment to get the value of needsInputModeSwitchKey?

I was trying to show my nextKeyboardButton based on the value of needsInputModeSwitchKey when the viewDidLoad or viewWillAppear.

nextKeyboardButton.isHidden = !self.needsInputModeSwitchKey

However, my Xcode console always showed this error when I call the key at viewDidLoad, viewWillAppear, viewWillLayoutSubviews and viewDidLayoutSubviews.

2024-10-15 11:50:34.306515+0800 MyKeyboard[6040:25025964] [External] -[UIInputViewController needsInputModeSwitchKey] was called before a connection was established to the host application. This will produce an inaccurate result. Please make sure to call this after your primary view controller has been initialized.

The timing of connection was established to the host application. probably not related to the life cycle of extension? What's the right way use this key without warning?

What is the right moment to get the value of needsInputModeSwitchKey?
 
 
Q