https://en.wikipedia.org/wiki/Identification_friend_or_foeHistory
With the successful deployment of radar systems for air defence during World War II, combatants were immediately confronted with the difficulty of distinguishing friendly aircraft from hostile ones; by that time, aircraft were flown at high speed and altitude, making visual identification impossible, and the targets showed up as featureless blips on the radar screen. This led to incidents such as the "battle of Barking Creek", over Britain, and the "air attack on the fortress of Koepenick", over Germany.
I have another question::
Why dont IR missiles head to sun?
How can missiles distinguish sun from other source of IR?