Hmm maybe that's why Shanks made a side trip to Elbaf then. He knew Luffy will come and he decided to reveal his location to Loki (with a vivre card ?) for him to tell him where to go after him after coming in Elbaf
But that's without knowing at the time that Blackbeard would already end him
Although it's also possible that he is anticipating something bad would happen to him and thus living a final message where Luffy would come