Skip to content

Conversation

vic-flair
Copy link
Contributor

Stores Personalization metadata in database along with Remote Config parameters. Adds a RCNPersonalization class that logs Personalization events, and listeners that call that when get*() is called.


/// Adds a listener that will be called whenever one of the get methods is called.
/// @param listener Function that takes in the parameter key and the config.
- (void)addListener:(void (^_Nonnull)(NSString *_Nonnull, NSDictionary *_Nonnull))listener;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove this from the header file since we're just calling it internally within the RC SDK and not changing the public API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -284,6 +306,14 @@ - (void)loadConfigFromMainTable {
self->_defaultConfig = [defaultConfig mutableCopy];
dispatch_semaphore_signal(self->_configLoadFromDBSemaphore);
}];

[_DBManager loadPersonalizationWithCompletionHandler:^(BOOL success, NSDictionary *fetchedConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to fetchedPersonalization and activePersonalization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


if (handler) {
dispatch_async(dispatch_get_main_queue(), ^{
handler(YES, activePersonalization, fetchedPersonalization, nil);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the handler definition expects fetched and then active

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, too much copying and pasting.

@@ -331,6 +358,10 @@ - (FIRRemoteConfigValue *)configValueForKey:(NSString *)key {
@"Key %@ should come from source:%zd instead coming from source: %zd.", key,
(long)FIRRemoteConfigSourceRemote, (long)value.source);
}
if ([self->_configContent.activePersonalization count] > 0) {
[self callListeners:value.stringValue
metadata:self->_configContent.activePersonalization[key]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking: we mentioned that the listener approach would allow us to add other side-effects in the future, but given the current implementation all the listeners would be called specifically with personalization metadata, which limits the functionality we can add