Askribe iOS SDK
Askribe iOS SDK enables you to show questionnaire directly from your own mobile app.
SDK integration (Requires Deployment Target 9+)
Setup
Download the sample project which contains the Swift library.
Obtain the API key required to connect with Askribe servers from the Settings section in your Askribe questionnaire dashboard.
Displaying the survey
showQuestionnaire(askribeParams: askribeParams)
See the below section for a discussion on params
Params
AskribeParams has the following fields:
askribeKey- Type:
String - Required
- Obtain the API key required to connect with Askribe servers from the
Settingssection in your Askribe flow dashboard.
- Type:
configId- Type:
String - Required
- Type:
context- Type:
[String: VariableData] - Optional
- Description: Pass a list of Key-Value pairs to be substituted in the flow
- Type:
receiversEmailAddress- Type:
String - Required if
distributionTypeisAUTO_EMAIL
- Type:
receiversPhoneNumber- Type:
String - Required if
distributionTypeis one ofAUTO_SMS|AUTO_WHATSAPP|AUTO_VOICE
- Type:
slackUserId- Type:
String - Required if
distributionTypeisAUTO_SLACK
- Type:
webPushConfig- Type:
ContactWebPushConfig - Required if
distributionTypeisAUTO_PUSH_NOTIFICATION
- Type:
androidPushConfig- Type:
ContactAndroidPushConfig - Required if
distributionTypeisAUTO_ANDROID_PUSH_NOTIFICATION
- Type:
iOSPushConfig- Type:
ContactIOSPushConfig - Required if
distributionTypeisAUTO_IOS_PUSH_NOTIFICATION
- Type:
language- Type:
String - Optional
- Description: Use this parameter to set the language of the flow
- Type:
- Callback
- Type:
() -> void - Optional
- Description: Pass a function to be called when the questionnaire is finished.
- Type:
class VariableData: Codable {
var contextVariableType: ContextVariableType? = nil
var value: String? = nil
}
class CategoryValue: Codable {
var label: String? = nil
var value: String? = nil
}
class ContextVariableType: Codable {
var variableType: String? = nil
var categoryValues: Array<CategoryValue>? = nil
var nluEntityId: String? = nil
var blueprintId: String? = nil
var t1Type: ContextVariableType? = nil
var t2Type: ContextVariableType? = nil
}
class ContactAndroidPushConfig: Codable{
var fcmId: String? = nil
}
class ContactIOSPushConfig: Codable{
var apnsId: String? = nil
}
class ContactWebPushConfig: Codable{
var urlEndpoint: String? = nil
var key: String? = nil
var auth: String? = nil
}
Integrating Push Notifications
To setup push notifications for your app:
- Register for push notifications - Register for push notifications by calling
AskribeSDK.registerForPushNotifications(cdpId: String) - Enrich the contact, optionally - You can enrich the contact created in the above step by calling
AskribeSDK.enrichContact(_ contactEnrichmentDTO: ContactEnrichmentDTO) - Check the sample app - Check the sample app to see how to do custom configuration for notification clicks, action items, etc.
ContactEnrichmentDTO has the following properties:
var email: String? = nil; // Email Id of the user
var phone: String? = nil; // Phone Number of the user
var app: String? = nil; // Name of your app
var appUserId: String? = nil; // Id of the user in your app
var customFieldValues: Dictionary<String, String> = [:]; // Values for predefined custom fields
var cdpId: String? = nil; // ID of the cdp where you want to enrich the contact. This field is mandatory