Quick Start
Get up and running! ๐๐
Let's get you started! This guide will walk you through the most important steps
Install the SDK ๐ง
Our iOS SDK is distributed as as a SPM package (Swift Package Manager). Simply add a SPM dependency in Xcode on https://github.com/criticalmoments/criticalmoments
.
Create an API Key ๐
Create or sign into your critical moments account at https://beta.criticalmoments.io/account
Follow the steps to provide your app's information and create an API key
The API key is only valid for the app with the bundle ID you provide during setup.
Create your config file ๐
Create a JSON config file to your XCode project, starting with a template:
Create a copy of of the file
cmDevConfig.json
template file below, replacingYOUR_BUNDLE_ID
with your real bundle ID. This template includes a simple launch message which will help your verify the integration is working.Add the file to your Xcode project. Ensure you check the "Target Membership" box for your app.
In Xcode open "Project Settings" > "Build Phases" > "Copy Bundle Resources", and verify the file you just added to the project is listed. If not, add it!
Integrate the SDK into your app ๐งฉ
Add the following code snippet into your app.
Put it somewhere that will run right after app startup, such as AppDelegate.didFinishLaunchingWithOptions
Replace the
YOUR_API_KEY
string with your real API keyThe console will show a warning for now, but this will be resolved in a later step of this guide
In your App Delegate imports add:
In App Delegate's application(_:didFinishLaunchingWithOptions:)
add:
Startup work will be dispatched to background threads, and will not impact your app's startup time.
Test the integration ๐งช
Launch your app! If the integration is working, you should get an alert after startup driven by the template config file. It will tell you if your app was launched in landscape or portrait, and rotating your device/simulator then re-launching should give the opposite result.
Log important events (optional, recommended) ๐ช
The more Critical Moments knows about your user's behaviours, the better you can target and optimize with Critical Moments.
We recommend you log important events, including the important actions your users performs in app. See the events documentation for the suggested events and details.
Add custom properties (optional, recommended) ๐
Properties are datapoints used in targeting. The more useful data you add, the more powerful the targeting system can be.
We recommend you add the important properties like account_creation_date, has_subscription, and others. See the custom properties documentation for suggested custom properties, and API reference.
Setup a cloud config file โ๏ธ
For local development you can use your local JSON config file built into the app binary. However, production builds must use a signed config file, hosted on the web.
Read the Remote Control Docs for the best practices of picking a hosting provider, signing, and deploying your config.
Once deployed, set the release config URL using this code snippet in your App Delegate:
Update Anytime
Deploying the config file can be done outside of app releases, allowing you to update your apps behaviour without waiting for app reviews, or users to update their builds!
Start building ๐๏ธ
Remove the demo actions and triggers from your copy of cmDevConfig.json
and start building using the powerful combination of conditionals, events, properties, feature flags, and actions!
Some good places to start and get ideas:
Read our Concepts Overview to understand all the tools at your disposal.
Try our Demo App for an interactive demo of conditionals, themes, and actions.
Last updated