Skip to content

Conversation

paulb777
Copy link
Member

@paulb777 paulb777 commented May 19, 2020

Adds an activate API with a changed parameter in the callback. It replaces a deprecated API that set an internal error if there was no change.

Fixes #3586

The integration test infrastructure is implemented in #5633

Googlers: See accompanying API proposal.

/// Completion handler invoked by activate method upon completion.
/// @param changed Flag indicating whether or not the configuration changed.
/// @param error Error message on failure. Nil if activation was successful.
typedef void (^FIRRemoteConfigActivateChangeCompletion)(BOOL changed, NSError *_Nullable error)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you illustrate a bit on what the advantage is. I'm guessing using the boolean as first parameter will improve checking in swift but I don't know what exactly it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

It gives feedback to the API client about whether or not the config changed without an error being thrown. See #3586 for more on the issues caused by the other API.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, so this will align with Android.

Copy link
Member Author

Choose a reason for hiding this comment

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

And JS :)

@paulb777 paulb777 force-pushed the pb-activate-changed branch 4 times, most recently from 805c9d0 to eda90ad Compare May 26, 2020 19:16
XCTAssertEqual(status, RemoteConfigFetchStatus.success)
self.config.activate { changed, error in
XCTAssertNil(error)
XCTAssert(changed)
Copy link
Member

Choose a reason for hiding this comment

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

Tiny nit: Can you change this to XCTAssertTrue? I did a double take on it, I think explicitly saying True makes it more clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed! Done

@@ -59,6 +60,43 @@ class FakeConsoleTests: APITestBase {
waitForExpectations()
}

// Test New API.
// Contrast with testUnchangedActivateWillFlag in APITests.swift.
func testChangedActivateWillNotFlag() {
Copy link
Member

Choose a reason for hiding this comment

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

Should this also test the false, nil case where activate is called but no changes happened?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but that test doesn't need the FakeConsole and was added to APITests.swift

Base automatically changed from pb-rc-fake to master May 26, 2020 23:14
@paulb777 paulb777 force-pushed the pb-activate-changed branch from 3b6e88b to 58387fa Compare May 26, 2020 23:16
@paulb777 paulb777 merged commit 2affb24 into master May 27, 2020
@paulb777 paulb777 deleted the pb-activate-changed branch May 27, 2020 01:01
@firebase firebase locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Most recently fetched config is already activated" after remote config activate() call
6 participants