I am developing messaging app for iOS.
I keep users' phone numbers to the server but I don't keep contact names on the backend side.
When the user receives push notification from the server, server sends phone number and message content to the user in notification payload. I implemented application:didReceiveRemoteNotification:fetchCompletionHandler method to show local notification. I look up in local database for phoneContactName:phoneNumber pair and show local notification in the format: %phoneContactName%:%messageContent%
However, the hurdle is that I don't now how to execute this code when the app is not running. I tried to implement application:didFinishLaunchingWithOptions and check there for
NSDictionary *userInfo = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
but this code is not invoked.
So to solve the problem I would like to ask you what architectural model should I use. Should I keep contact names on the server side to send notification.alert from the server side with the name of contact (so far my server doesn't know the name of contact phone number) or is there any way to execute code when the app is not running?
P.S. Also, I calculate the badge number on the client side when notification is received. So, the code execution solution will be better if possible.
Thank you