In fact when you check tafsir books there are at least two different opinions on when it was revealed:
- some say after the battle of Khaybar (in the year 7 a.H. meaning 3 years before the Prophet's death), in that case it was actually revealed in Medina and was a promise or announcement of a future happening.
- Al-Wahidi الواحدي in his asbaab an-nuzul has chosen a narration saying it was revealed after the battle of Hunayn (after fath Mekka in the year 8 a.H.)
or
- at hajjat al-wada' حجة الوداع (a few months before the Prophet's death) in that case it was rather message for the close death of the prophet which many ahadith seem to emphasize as the hidden meaning (See for example in sahih al-Bukhari
But all tafsir's I have checked follow the opinion that it is a madani surah it was revealed after hijra (see Who defined the terms "makki" and "madani"? as) and speak about consensus on the matter.
Following a quote in fath al-Barry of ibn Hajar (also in other commentaries of sahih al-Bukhari like 'omdat al-Qari of al-'Ayni, irshad as-Sari of al-Qastalani... but without the reference to abu Ya'ala) saying that the hadith of ibn 'Omar was narrated via abu Ya'ala أبو يعلى الموصلي (A scholar of the 2nd hijri century).
ولأبي يعلى من حديث ابن عمر " نزلت هذه السورة في أوسط أيام التشريق في حجة الوداع ، فعرف رسول الله - صلى الله عليه وسلم - أنه الوداع "
This would mean it was revealed while the Prophet and his companions were still performing Hajj so they were -locally- close to Mekka! Ibn Hajjar himself quoted it in his book al-Matalib al-'Aliyah bizawa'id al-Masaneed a-Thamaniya المطالب العالية بزوائد المسانيد الثمانية from Munsad ibn abi Shaybah أبو بكر بن أبي شيبة (One of the teachers of al-Bukhari and Muslim: here and here with the addition in Mina) and Musnad abu Ya'ala (only quoted under the first quote from Musnad ibn abi Shaybah).
I found the tradition narrated on the authority of ibn 'Omar quoted in as-Sunan al-Kubra of imam al-Bayhaqi:
عن ابن عمر رضي الله عنهما قال : أنزلت هذه السورة { إذا جاء نصر الله والفتح } على رسول الله - صلى الله عليه وسلم - في وسط أيام التشريق ، وعرف أنه الوداع ، فأمر براحلته القصواء فرحلت له ، فركب فوقف بالعقبة ، واجتمع الناس فقال : " يا أيها الناس . . . "
This tradition says that the surah was revealed during the days of tashreeq! As is the only indication for a quotr of a location is that the prophet () stood at al 'aqabah (Mina) to held a sermon afterwards. Al-Bayhaqi has quoted the same narration in his dalaail an-Nubuwa.
And here's a link to the version from musnad al-Bazzaar:
عَن ابْنِ عُمَر قَالَ: نَزَلَتْ هَذِهِ السُّورَةُ عَلَى رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيه وَسَلَّم بِمِنًى، وهُو فِي أَوْسَطِ أَيَّامِ التَّشْرِيقِ فِي حَجَّةِ الْوَدَاعِ {إِذَا جاء نصر الله الفتح} فَعَرَفَ أَنَّهُ الْوَدَاعُ فَأَمَرَ بِرَاحِلَتِهِ الْقَصْوَاءِ فَرُحِّلَتْ لَهُ ....
which includes the addition in Mina and hajjat al-Wada'.
Note that all these similar narration have been narrated based on (common part of the ) the chain:
Zaid ibn al-Hobab زَيْدُ بْنُ الْحُبَابِ
from Musa ibn 'Obaydah، مُوسَى بْنُ عُبَيْدَةَ
from Sadaqah ibn Yasar ، صَدَقَةُ بْنُ يَسَارٍ
from ibn 'Omar ، عَنِ ابْنِ عُمَرَ
@III-AK-III has already given a qualification of the narrator chain