objective c - iOS push notification alert message based on data in alert -
all,
i sending push notifications data in string. example:
{ "aps": { "alert": "1,friendsname,3,4,pink, green", "sound": "default" } } or
{ "aps": { "alert": "2,drinks, adress", "sound": "default" } } now, want message in alert show text, based on values in string. (pseudo-code): if first character in "alert" = 1 => "alert = @"color %@ %@", friendsname, pink
if first character in "alert" = 2 => `"alert = @"invite %@ @ %@", drinks, adress
is possible @ all? , if so: how?
no not possible in way want. ios handles push notification , app has no influence on way notification presented. ios present send in notification.
however can use localization achieve want:
"alert" : { "loc-key" : "alert_format", "loc-args" : [ "friendsname", "pink"] }, where alert_format localization in localizable.strings file:
"alert_format" = "color %@ %@" but have change type of notification on server, notification send invite need change notification on server.
so send invite:
"alert" : { "loc-key" : "alert_invite", "loc-args" : [ "drinks", "adress"] }, where alert_invite localization in localizable.strings file:
"alert_invite" = "invite %@ @ %@" so json push notification should like:
{ alert" : { "loc-key" : "alert_format", "loc-args" : [ "friendsname", "pink"] } }
Comments
Post a Comment