* Added Remote Config Console API and some tests * Added workflow scripts * Update path in remote config workflow * Update path in remote config workflow 2.0 * Adding print statements to debug * Update generate_access_token.sh * Style and script cleanup * Updated README and script * reordering workflow tests for faster dev * Updated generate_access_token.sh * Removed unneeded part of path * Set env var in GHA rather than script * Fix env var in GHA * Fix env var in GHA 2.0 * Refactored actions into one script * removed back slash * Removed unneeded workflow step * Refactored script and added comments * Minor tweaks * Added new line * well nvm that tweak * Reordered workflow steps back to original order * Only generate access token for ios runs * Fixed readme, organized tests, improved RemoteConfigConsole * Fixed test * reordering tests for dev * Removed README.md * Added local dev mode for script * Reset the ordering of tests to original order * Update README * Update README again * Trailing space * trailing space..again * Cleanup up cloned repo in script * Resolved feedback * Style * Gotta love trailing spaces * Resolved feedback 2.0 * Resolved feedback 3.0 * Changed param type for update APIs * Fixed type in updateRemoteConfigValue method
Remote Config Console API
RemoteConfigConsole.swift
provides a simple API for interacting with an app's Remote Config on the
Firebase console.
Local Development Setup
- Create a Firebase project on the Firebase Console and download
the
GoogleService-Info.plist. - Navigate to your project's settings. Click on the Service accounts tab and
then download a private key by clicking the blue button that says "Generate new private key".
Rename it
ServiceAccount.json. - Within the
firebase-ios-sdk, run:
./scripts/generate_access_token.sh local_dev PATH/TO/ServiceAccount.json FirebaseRemoteConfig/Tests/SwiftAPI/AccessToken.json
- Generate the
FirebaseRemoteConfigproject:
pod gen FirebaseRemoteConfig.podspec --local-sources=./ --auto-open --platforms=ios
- Copy the
GoogleService-Info.plistyou downloaded earlier into the generated Xcode project.
🚀 Everything is ready to go! Run the tests in the swift-api-tests target.
How it works
While the RemoteConfigConsole API basically just makes simple network calls,
we need to include an access token so our requests do the proper "handshake" with the Firebase console.
Firebase Service Account Private Key
This private key is needed to create an access token with the valid parameters that authorizes our requests to programmatically make changes to remote config on the Firebase console.
The private key can be located on the Firebase console and navigate to your project's settings. To download, click on the Service accounts tab and and then generate the private key by clicking the blue button that says "Generate new private key".
Create the Access Token
We use Google's Auth Library for Swift
to generate the access token. There are a few example use cases provided. We use the
TokenSource
example.
For the access token to be generated, the GOOGLE_APPLICATION_CREDENTIALS env var should be set to point to where the
Firebase project's service account key is stored. This is set in the
generate_access_token.sh
script.
Remote Config API Tests
There is a section
of tests in APITests.swift
showcasing the RemoteConfigConsole in action.