In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
2- However, if you see blood a day or two before giving birth, that blood is considered post-partum bleeding. Therefore, you do not pray.
Answering your question, Sheikh `Abdullah ibn Jibreen, the late prominent Saudi Muslim scholar, stated:
The woman prays whenever she is free of menstruation and post-partum bleeding. However, if you see blood a day or two before giving birth, that blood is considered post-partum bleeding. Therefore, you do not pray.
On the other hand, if you do not see any blood, then you continue praying even if you are having labor pains, in the same way that an ill person prays while feeling the pangs of his illness. He still has to pray as long as he is conscious.
Almighty Allah knows best.
Source: Islamic Fatawa Regarding Women, Compiled by Muhammad Ibn Abdul-Aziz Al-Musnad and translated by Jamal Al-Din Zarabozo, Darussalam, 1996.