If you're not truly running in the background, but suspended
then your app will not receive any events until it is awakened by the user or relaunched. If you are running in the background you'll need to poll for changes in the settings bundle and react accordingly.
How can I update the NSUserDefaults from the Settings Bundle while the app is running in background?
-
03-07-2022 - |
문제
In the settings bundle, I've got a multi choice option. So when I choose something, the app should receive the new value and use it to launch a UILocalNotification. What I've tried, only updates the values when I open the app.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(defaultsChanged:)
name:NSUserDefaultsDidChangeNotification
object:nil];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[NSUserDefaults standardUserDefaults]synchronize];
}
해결책
제휴하지 않습니다 StackOverflow