4

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\":" + 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?

Daverix
  • 399
  • 2
  • 16

1 Answers1

0

Try to use:

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

This will dynamicaly get the correct string.

Mats Stijlaart
  • 5,058
  • 7
  • 42
  • 58
  • Yes but now the problem is that when you get a notification in IOS it still doesn't work. I have never had any problems inside the app itself. Just that it can't retrieve the message from the Localizable.strings file for some reason. – Daverix Feb 20 '11 at 22:14
  • So you get a string from the server, and you want to convert that message to the correct localisation? – Mats Stijlaart Feb 20 '11 at 22:26
  • 1
    Yes, the loc-key and loc-args, is converted to the localized string on the phone. For information of how the remote push notifications work, look here: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html – Daverix Feb 21 '11 at 07:53
  • Is it possible that we can give localization alert in two languages and depending upon the language of iPad the correct text is shown in notification – Shajo Mar 25 '15 at 17:52