Push Notification showing localization constant instead of message

I have a serious problem that I have not found on the network. When I click on a localized message, it only works in Swedish, not English. I have another one that says it only shows constant for their Swedish Iphone 4. I also tested on Iphone 3g and it has the same problem as my iphone 4, it works in Swedish not in English.

When a popup for Iphone 4 is displayed in English, I get only the localization key, which I will put in my notification from the server.

Here is the notification line in C # that I press with Windows Server. The extra options for my iphone application work completely in any language, so it seems like it has nothing to do with the server side part.

int total = notification.AmountScheduledEvent + notification.AmountCourseResult + notification.AmountExam; string locKey = (total > 1 ? "PushMessageMultiple" : "PushMessageSingle"); string msg = "{\"aps\":{"+ "\"alert\": {"+ "\"loc-key\":\"" + locKey + "\","+ "\"loc-args\":[\"" + total + "\"]},"+ "\"badge\":" + total + ","+ "\"sound\":\"default\"},"+ "\"amountSchedule\":" + notification.AmountScheduledEvent + ","+ "\"amountCourseResult\":" + notification.AmountCourseResult + ","+ "\"amountExam\":" + notification.AmountExam + "}"; 

In my Localizable.strings in sv.lproj:

 /* push stuff */ "PushMessageMultiple" = "%@ nya hรคndelser"; "PushMessageSingle" = "1 ny hรคndelse"; 

In my Localizable.strings in en.lproj:

 /* push stuff */ "PushMessageMultiple" = "%@ new events"; "PushMessageSingle" = "1 new event"; 

Here is a screen shot of a notification that works (Swedish) http://img267.imageshack.us/i/img0014b.png/

Here is a screen shot of a notification that doesnโ€™t work (in English) http://img696.imageshack.us/i/img0015i.png/

Any idea why I get a constant instead of a message?

+4
source share
1 answer

Try using:

 NSLocalizedString(@"PushMessageMultiple",@""); 

This will dynamically get the correct string.

0
source

Source: https://habr.com/ru/post/1340534/


All Articles