Nudges - Integrating the SDK
Important
Nudge SDK is available for integration from Smartech SDK v3.1.0 onwards.
1. Create the App from Hansel Dashboard
Please get in touch with your account manager to create app on Hansel dashboard.
Once the app is created, here's what the 'App Settings' screen on your Hansel dashboard will look like before you integrate the SDK.
Prerequisite
iOS SDK is available for integration via Cocoapods. If you do not have Cocoapods installed already, follow these instructions on the Cocoapods website to install it.
Xcode support
Hansel SDK only supports Xcode 11 and above.
Step 1: Add Hansel to podfile
a. Cocoapods initialization
Open terminal, go to the project directory and run the following command:
pod init
This will create a podfile in your project directory.
b. Add Smartech-Nudges to target
In the podfile, add the following line to app's target:
pod 'Smartech-iOS-SDK' , '~> 3.1.0'
pod 'SmartechNudges', '~> 8.5.0'
For e.g. if you want to install Smartech-Nudges pod to "Gretel" target, your podfile will look like:
target 'Gretel' do
pod 'Smartech-iOS-SDK' , '~> 3.1.0'
pod 'SmartechNudges', '~> 8.5.0'
end
c. Pod install
Open terminal, go to the project directory and run the following command:
pod install
This will install the SDK in your project. Once that is done, close the Xcode project and open <app_name>.xcworkspace in the project directory.
Using .xcworkspace
Henceforth, .xcworkspace should be used to open this project in Xcode.
Step 2: Updating Capabilities
In Xcode target, go to Signing & Capabilities, and click on "+Capability" as shown below, if you do not have any "Keychain Groups" setup. If you do, you can directly proceed to the next step.
Add a new Keychain Group (as shown below) and enter hansel_public_key (Hansel uses KeyChain Sharing for decryption of Hansel SDK's responses)
Step 3: Configure Apps Info.plist with Hansel Keys
You need to add a key named HanselKeys with type Dictionary. Init add the following keys and values with their types.
Key | Data type | Description |
---|---|---|
HanselAppId | String | The app id received from Hansel panel under app settings section. |
HanselAppkey | String | The app key received from Hansel panel under app settings section. |
Following is the source code snippet of apps Info.plist for key Hansel Keys:
<key>HanselKeys</key>
<dict>
<key>HanselAppId</key>
<string>value of app id</string>
<key>HanselAppKey</key>
<string>value of app key</string>
</dict>
Following is the image representation of apps Info.plist for key HanselKeys:
Next steps in setting up Nudges
Once you have successfully integrated the SDK, ensure that you set up test devices. To learn more, click here
Updated over 3 years ago