开发者

Push Notification showing localization constant instead of message

开发者 https://www.devze.com 2023-02-12 19:11 出处:网络
I have a serious problem I have not found any questions about on the net. When I push a localized message it only works for Swedish and not English. I have another that says that it only shows a const

I have a serious problem I have not found any questions about on the net. When I push a localized message it only works for Swedish and not English. I have another that says that it only shows a constant for their Swedish Iphone 4. I have also tested on Iphone 3g and it has the same problem as my iphone 4, works in swedish not in english.

When displaying a popup for Iphone 4 in English, I only get the localization key I supply in my notification from the server.

Here is the string of the notification in C# that I push from a Windows Server. The extra parameters for my iphone app works totally fine in any language so it seems it has nothing to do with the server side part of the push.

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\开发者_StackOverflow中文版":" + 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 picture of the screen with a notification that works (Swedish) http://img267.imageshack.us/i/img0014b.png/

Here is a picture of the screen with a notification that doesn't work (English) http://img696.imageshack.us/i/img0015i.png/

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


Try to use:

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

This will dynamicaly get the correct string.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号