I am working on a booking app. And I would like to send a notification to user when there the booking status is update.
So I write some json in server side like this:
{
"aps":
{
"alert": "update status",
"category" : "booking approve", //can be "booking cancel" , "booking reject"
}
}
And in the IOS side
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
let aps = userInfo["aps"] as! [String: AnyObject]
// need to customize and create notification message here
}
The problem is , how can I customized the message (according to the user language) after receive the status tag (e.g. booking approve) from the push notification?
Thanks for helping.
You should look at the Remote Notification Payload guide which lists all the key available for the notifications. The one you are looking for is loc-key :
loc-key : A key to an alert-message string in a Localizable.strings file for the current localization (which is set by the user’s language preference). The key string can be formatted with %@ and %n$@ specifiers to take the variables specified in the loc-args array. See Localized Formatted Strings for more information.
Instead of sending a string in a arbitrary chosen language, send this key and the alert will show a translated text, according to the localisations available for your app.
Also, since iOS 8.2, title-loc-key is available for the title displayed in Apple watch when receiving a notification.