Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification Service Extensions with NSLocalizedString

I am using Notification Serivce Extension to change the text coming from the server as per what I Want.

However, that was working good with normal strings. but when I used NSLocalizedString with it, it dosent show the localized string, instead it shows the field name of the string.

For example: inside the UNNotificationServiceExtension:

let CompanyViewLM = NSLocalizedString("Notifications.View", comment: "No Comment")

and in Localizable.strings I put the following line:

Notifications.View = "I Viewed your profile";

Noting that I put the same lines of code in a normal view controller and it works just fine.

like image 495
FamousMaxy Avatar asked Jul 06 '17 16:07

FamousMaxy


1 Answers

I Found by my self what was the problem. The notification service target was working in the project without recognizing other files of the project.

To make it recognizes other files you must go to targets -> NotificationService -> Copy Bundle Resources -> add the files you want the notification service to work with.

In my case, I added the Localizable.strings file and it worked as a charm.

like image 60
FamousMaxy Avatar answered Oct 17 '22 10:10

FamousMaxy