2

I have two applications that share an app group @"group.edu.tds.poc.shared"

Using NSUserDefaults of this app group, I am able to exchange data between the reader app and the writer app.


The Writer App writes data to the NSUserDefault

NSUserDefaults *sharedDefaults =
    [[NSUserDefaults alloc] initWithSuiteName:@"group.edu.tds.poc.shared"];

    [sharedDefaults setObject:stringToStore forKey:key];
    [sharedDefaults synchronize];

The Reader App reads the data from the NSUserDefault

 NSUserDefaults *sharedDefaults =
    [[NSUserDefaults alloc] initWithSuiteName:@"group.edu.tds.poc.shared"];
    return [sharedDefaults stringForKey:@"key"];

I now want the reader app to be notified as soon as the writer app modifies the value for the key. I.e. Can I notify the reader app when the writer app is running in the foreground (Reader app is either running in the background or is not running).

I have implemented the marked solution but with no luck:

Call back only when the Reader App is in foreground state. (Wrote to the Shared Defaults using Reader app)


Any idea if this can be achieved?

Sandeep T D S
  • 481
  • 3
  • 15
  • 1
    If an app is in the background or is not running, then no code is running so it can't respond to any changes. – Abizern Aug 17 '17 at 13:45

0 Answers0