Reputation: 1287
I am receiving a native language in the 'alert' tag in the push notification. Due to some issues with string encoding the message is shown as roman characters. So I want to fetch the message in the 'alert' tag and edit it before showing it as the notification. I tried didReceiveRemoteNotification callback and I don't think it's being called. How can I do this?
Upvotes: 1
Views: 651
Reputation: 4047
There's a different behaviour for push notifications when the app is in the foreground/background and when the app isn't running at all. When the app is running, whether in the foreground, you'll receive a call to didReceiveRemoteNotification:
and you'll be responsible for handling the notification's display (the operating system won't do it for you).
When the app is in the background, you'll receive a call to didReceiveRemoteNotification:
only if/when the user presses the notification banner/alert displayed to him/her by the operating system. If the user chooses not to interact with the notification, your app won't even know about it.
If the app isn't running at all, the behaviour will be similar to when the app is in the background, only you'll receive the push notification indication and data in the userInfo dictionary of application:didFinishLaunchingWithOptions:
So, if your question refers to cases in which the app is in the foreground, that shouldn't be a problem and you can do anything you want with the alert field before displaying it to the user. Otherwise, it's the operating system's responsibility to show the alert so that makes it a bit more complicated. Try using the tools available to you for localizing the alerts, as described here: Change language of alert in banner of Push Notification. Hopefully, it will help. Good luck.
Upvotes: 2