How to get call on an extension, which register when a call towards it reach Asterisk?

I am trying to develop a scenario where an extension gets registered on Asterisk when it receives a push notification. This push notification is sent to the sip extension when a call towards this extension reaches to the Asterisk.

For example, suppose there is two SIP extension( extension 1 and extension 2) registered on Asterisk. When a call from extension 1 reaches the asterisk, it forwards the INVITE request towards extension 2. suppose the extension 2 is not able to receive the INVITE request from Kamailio. When extension two receive a push notification, it will register on asterisk.
So I need to get the call on extension 2 through the new registration.

We are trying to simulate registration of extension to the asterisk when receiving the push notification.
First, we registered extension 2 and disconnected the network. Then we tried to register the same extension when a call from extension 1 reaches to Asterisk. This is a simulation of push-based registration since an extension that receives the push will attempt to register when an incoming call is received.

Even though new registration of extension reached to Asterisk, it tries to retransmit the INVITE request to the old port.

This is the problem for me since push relies on the INVITE reaching the phone at the correct port number.

So, is there other good approaches to solve this issue?

Once a call is set up the target isn’t changed, even if a registration is received. You need to wait for the push to be confirmed and for the new registration to occur.

How can you push to a device whose address you don’t know? The purpose of SIP Register is to inform the registrar of how to reach the device with the given address of record. If you already know the IP address, you should not be using dynamic hosts.

It generally uses a push notification system where each application registers and gets a token that is communicated back to the server. The server provides the token to the push notification system which communicates the push notification down to the device and application that then does something as a result.