How to localise Service Extension and access APPDelgate property in Service Extension

て烟熏妆下的殇ゞ 提交于 2019-12-10 12:21:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!