I imagine that most iPad Pro users will have this problem at some point, where, even though the keyboard is attached properly, you get the virtual keyboard instead, and ‘accessory not supported’ is indicated. Most people, after suffering with this for some time, just get a replacement keyboard - whether another Apple one (where it will probably happen again) or a 3rd party keyboard. While suffering with this with my iPad Pro, I’ve found out a number of things. Connecting the ipad to the keyboard initially, via the 3 tiny pins/magnets, is actually not the problem.
The problem arises when you attempt to ‘snap’ the affixed keyboard to the groove, just above the typing keys. I found this out by having the accessory not supported box indicated when the keyboard was first attached, but being able to remove it (and have the keyboard work) by shifting the keyboard around in that long groove, and or ‘resnapping’ it on to that groove a few times, which caused the keyboard to work again. A workaround is to have that groove just above the keys cleaned REALLY well...which I did and the keyboard actually worked for a number of days with no issues. I have had to continually do this. Sadly, there is no Apple store near me so, all patience aside, I’ve finally ordered a 3rd party keyboard, and will use the Smart (or not so Smart) keyboard as a spare......