There isn’t a simple answer to this question because the introduction of any dog to gunfire is a fairly lengthy process.
I usually start by getting a helper to let off a starting pistol blank from a distance of 200 yards and then, very gradually, move closer over a period of time.
The golden rule is to only fire a shot when the dog is doing something it enjoys and is happy (this could be eating or playing, followed by a retrieve after the pistol has been fired).
If done in a sensible manner it is highly unlikely that this will be an issue to the dog and can be done from the age of six months on – but as usual everything is dependent on the character of the dog.
When my pups are young I get them used to something simple like dropping a noisy dinner bowl and having them around me in the kennel – you want them to be unafraid of loud, unfamiliar, sounds.