问题
I have two quostions related to the Service Extension
1. How to localise Service Extension
I have supported 2-3 languages in my app, a user can select any language and app will get displayed in that language. I haven't used the device language. All is working fine.
I want to display push notification based on user selected language. I used Service Extension and It is working but getting all notifications in English(default development) language.
I have created LocalisationManager singleton class
which changes my app bundle
using user language selection. The iOS app content gets localised but unable to localise the Service Extension
text. I can access LocalisationManager singleton class
in Service Extension class
but my text is not getting changed.
Is there any way to handle this?
2. How to access APPDelgate property in Service Extension
I used NSUserDefaults to share data from app to extension. Reference URL
NSUserDefaults *sharedUserDefault = [[NSUserDefaults alloc] initWithSuiteName:@"group.mygroup"];
[sharedUserDefault setObject:object forKey:@"key"];
NSUserDefaults *sharedUserDefault = [[NSUserDefaults alloc] initWithSuiteName:@"group.mygroup"];
sharedUserDefault value = [sharedUserDefault valueForKey:@"key"];
But there any other way to access Singleton class
of the app in Extension? Like my iOS app and Extension will refer the same Singleton class
, so only one object of this class will get created.
来源:https://stackoverflow.com/questions/54133966/how-to-localise-service-extension-and-access-appdelgate-property-in-service-exte