Although the two perspectives, that of the pole and that of the barn, have different measurements of the each other, they agree on their differences. That is, the observer in the pole’s frame agrees that the observer in the barn’s frame will measure the pole to be shorter than it is in the pole’s frame. The opposite is true with respect to the barn.
Now, if the dynamite is fixed to the barn, then the pole will fit the barn from the barn’s perspective, and the observer in the pole’s frame knows this. Hence, the dynamite will explode, and both observers agree it will (at least before the explosion). Alternatively, if the dynamite is fixed to the pole, then it will not explode, and both observers will agree on this.