That hasn't been historically true. It might be true for newer ones but older designs could have gone off. There's also incidents where the bomb was armed accidentally, say, by it slipping while in a plane. Some of the "intentional" detonators were very simple and could be triggered by a surge.
Not only that, but designs thought to be "one-point safe" (a detonation starting at one point in the explosive lens will not cause a significant nuclear chain reaction) actually turned out to cause significant nuclear yield if detonated from one point. Same source.
Source: https://www.amazon.com/Command-Control-Damascus-Accident-Ill...