This document is just a quick start introduction to Liquid SDK for iOS. You can read the full documentation at https://www.onliquid.com/documentation/ios/.
To integrate Liquid in your app, just follow the simple steps below.
-
Install CocoaPods in your system
-
Open your Xcode project folder and create a file called
Podfile
with the following content:pod 'Liquid'
-
Run
pod install
and wait for CocoaPod to install Liquid SDK. From this moment on, instead of using.xcodeproj
file, you should start using.xcworkspace
.
To install Liquid for an watchOS project, you need to explicitly define the platform for each of your targets, in your Podfile, like shown below:
target 'Example' do
platform :ios, '5.0'
pod 'Liquid'
end
target 'ExampleApp WatchKit Extension' do
platform :watchos, '2.0'
pod 'Liquid'
end
target 'ExampleApp WatchKit App' do
platform :watchos, '2.0'
pod 'Liquid'
end
target 'Example TV App' do
platform :tvos, '9.0'
pod 'Liquid'
end
In your AppDelegate.m file initialize Liquid in application:willFinishLaunchingWithOptions:
method:
#import <Liquid/Liquid.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
# ifdef DEBUG
[Liquid sharedInstanceWithToken:@"YOUR-DEVELOPMENT-APP-TOKEN" development:YES];
# else
[Liquid sharedInstanceWithToken:@"YOUR-PRODUCTION-APP-TOKEN"];
# endif
// The rest of your code goes here...
}
If all your users are anonymous, you can skip this step. If not, you need to identify them and define their profile. Typically this is done at the same time your user logs in your app (or you perform an auto login), as seen in the example below:
[[Liquid sharedInstance] identifyUserWithIdentifier:@"UNIQUE-ID-FOR-USER"
attributes:@{ @"gender": @"female",@"name":@"Anna Lynch" }];
The username or email are some of the typical user identifiers used by apps.
You can track any type of event in your app, using one of the following methods:
[[Liquid sharedInstance] track:@"clickedProfilePage"];
Or:
[[Liquid sharedInstance] track:@"boughtProduct"
attributes:@{ @"productId": 123 }];
To send Push Notifications or In-App Messages to your users' devices through Liquid formulas you just need to configure those three delegation methods:
// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
return YES;
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[[Liquid sharedInstance] setApplePushNotificationToken:deviceToken];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[[Liquid sharedInstance] handleRemoteNotification:userInfo forApplication:application];
}
You can transform any old-fashioned static variable into a "Liquid" dynamic variable just by replacing it with a Liquid method. You can use a dynamic variable like this:
NSString *text = [[Liquid sharedInstance] stringForKey:@"welcomeText"
fallback:@"Welcome to our App"];
We recommend you to read the full documentation at https://www.onliquid.com/documentation/ios/.
Liquid Data Intelligence, S.A.
Liquid is available under the Apache license. See the LICENSE file for more info.