IOS UiLocalNotification formatting

I am adding local notifications to my current project and I noticed something strange. What I am doing is displaying alerts when a piece of equipment has a dead battery. When the application is in the foreground (and I replace the notification with a warning), the line is displayed normally. However, when the application is in the background, my percentile sign disappears.

    @"%@ has less than %i%% battery left!"

is the string I'm using. Something like “X has less than 10% battery left!” Appears in the warning view. but a background notification shows that "X has less than 10 bits left!"

Has anyone come across this before?

edit (add code snippet)

UILocalNotification *lc = [[UILocalNotification alloc] init];
lc.fireDate = [[NSDate alloc]init];
lc.alertBody = [NSString stringWithFormat:@"%@ has less than %i%% battery left!", name, percentage];

lc.timeZone = [NSTimeZone defaultTimeZone];
lc.applicationIconBadgeNumber = lc.applicationIconBadgeNumber + 1;

[[UIApplication sharedApplication] scheduleLocalNotification:lc];

Where is the name NSString and the percentage is int

+4
2

, .

:

@"%@ has less than %i %%%% battery left!"

[NSString stringWithFormat:@"%@ has less than %i %@ battery left!",@"Your App",7,@"%%"]

:

@"%@ has less than %i%% battery left!"
+2

, , . :

@"%@ has less than %i\uFF05 battery left!"

, .

+5

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


All Articles