No such thing as an unlock code in the context of iPhones. iPhone lock/unlock status is all done through the activation tickets. When you insert a SIM and try to activate it, the phone requests a ticket from Apple's servers. The server looks at the IMSI, verifies that the phone is allowed to get such an activation ticket, and then delivers that to the iPhone.
If your phone was activated before unlocking, and you put a SIM card in for a carrier that isn't allowed by the current ticket (different IMSI), the phone will request a new ticket from the activation server. If the phone is now in the "unlocked" list on Apple's server, the server will issue a new ticket that is valid for any SIM. If the phone is *not* allowed to receive an activation ticket for that carrier (i.e. it's still locked), then the phone will display a message saying "unable to activate iPhone" and refuse to let you do anything until you remove the SIM.
There is no need to restore unless you really want to see the "congratulations" message. It used to be necessary in the past when iTunes was required for activation, but that hasn't been the case for a long time.
There's no time limit. As soon as the carrier sends you the email saying the phone is unlocked, that's how the phone is noted in Apple's server. The next time you request an activation ticket (whether it's due to inserting a new SIM or restoring the phone), Apple will deliver a "wildcard ticket" (which is an unlocked activation ticket)
Thank you sir.. this is the clearest explanation I have read so far... and also the one that makes the most sense.
So, Apple server ticket and SIM system.
Locked:
1. Activate a SIM i.e. ATT
2. Apple server recognizes its locked and sends activation ticket only for ATT
3. Activation ticket only matches with ATT, hence locked to ATT.
Unlocked:
1. Activate a SIM i.e. ATT or Tmobile
2. Apple recognizes its unlocked and sends an unlocked activation ticket which works to any carrier, i.e. Tmobile and ATT
3. Activation ticket "unlocked" should work with any SIM.
so that means, Apple screwed up because 1. My full priced phone should have been unlocked and the server should've recognized it is not tied to a subsidy or a NEXT plan. 2. I should've gotten an "unlocked" server ticket which would've enabled me to put any simcard at that point regardless of activation.
WTF, all the Apple "know it all" agents would swear it was ATT who locked my phone once i activated it with them... they straight up lied to me. They were even dismissive and when they talked to me to the point that they were arguing that its their way or the highway. I told them that's not the case but they still insisted. Bunch of USELESS know it all people.