Template definition
The template definition is done inside the file definition.json
. A JSON schema is provided so that you can validate the correctness of the file. You can reference the JSON schema from withing the file, like this:
{
"$schema": "https://api.follow-apps.com/json-schemas/inapp-templates/v1_0_0.json"
}
Once you have added the reference to the schema, your code editor will provide syntax highlighting and code completion assistance.
Library options
The first section of definition.json
contains meta data information about the template. These options will only be used for organising the library and they will not be transferred to the SDK and the final device.
- Technical name: It is a way to identify the template. If missing, the name of the template's zip file will be used as technical name.
{
"template_options": {
"technical_name": "123"
}
}
- Title: The title of the template. The title is displayed in the library, under the template's thumbnail. It accepts multiple translations. If a language is missing, the Enlgish translation is going to be used. If the English translation is missing as well then the technical name will be used.
{
"template_options": {
"title": {
"en": "A title",
"fr": "Un titre"
}
}
}
- Description: A description of the template to be used in the library
{
"template_options": {
"description": {
"en": "The description here.",
"fr": "La description ici."
}
}
}
- Author: The author of the template.
{
"template_options": {
"author": "My name here"
}
}
- Version: The version of the template.
{
"template_options": {
"version": "1.0.0"
}
}
SDK options
The second section of definition.json
contains instructions on how the template will be displayed inside the device by the SDK.
- Type: Either
"fullscreen"
(which is the default) or"popup"
. This option will be used by the library in order to put the template in the correct list.
{
"sdk_options": {
"type": "popup"
}
}
-
Close button: By default, the SDK will add a close button on the top right corner of the template. This is not always desirable. You can control this behaviour with the
appear_timeout
option of the close button. There are three possible behaviours: -
"appear_timeout": 0
: This is the default behaviour. The SDK adds a close button on the top right corner upon displaying the message.
{
"sdk_options": {
"close_button": {
"appear_timeout": 0
}
}
}
"appear_timeout": 10
(or some other delay in seconds): The SDK will add the close button 10 seconds after displaying the message. Until then, there is no way to dismiss the message and the user is locked. This option is useful for displaying content that cannot be skipped.
{
"sdk_options": {
"close_button": {
"appear_timeout": "10"
}
}
}
"appear_timeout": "never"
Use this option if you want to disable the automatic close button. You can create your own button by calling the methodFollowAnalytics.CurrentCampaign.close()
in Javascript.
{
"sdk_options": {
"close_button": {
"appear_timeout": "never"
}
}
}
Inputs
Field Types
String
- if placeholder is empty, then this will be the default
{
"inputs": [
{
"type": "string",
"default": "something",
"min_lenght": 3,
"min_lenght": 100,
"lines": 3,
"placeholder": "myapp://path/to/content or http://your.url"
}
]
}
Enum
{
"inputs": [
{
"type": "enum",
"default": "test1",
"values": [
{ "value": "test1", "caption": { "en": "test 1", "fr": "test 2" } },
{ "value": "test2", "caption": { "en": "test 2", "fr": "test 2" } }
]
}
]
}
Number
{
"inputs": [
{
"type": "number",
"default": 15,
"precision": 0,
"min": 3,
"max": 100
}
]
}
Boolean
{
"inputs": [
{
"type": "boolean",
"default": true
}
]
}
Note: The default value for the default
field is false
.
Color
{
"inputs": [
{
"type": "color",
"default": "#1ab9b1"
}
]
}
Image
{
"inputs": [
{
"type": "image",
"default": "./image.jpg",
"max_filesize": 10000000
}
]
}
Video
{
"inputs": [
{
"type": "video",
"default": "./video.mp4",
"max_filesize": 20000000
}
]
}
Groups
{
"inputs": [
{
"type": "group",
"label": {"en": "my group"},
"tooltip":{"en":"my tooltip"},
"inputs": []
}
]
}
Note: the array inputs
accepts all other inputs except for group and table.
Tables
{
"inputs": [
{
"type": "table",
"label": {"en": "my table"},
"tooltip": {"en":"my tooltip"},
"max_size": 3,
"min_size": 1,
"inputs": []
}
]
}
Note: the array inputs
accepts all other inputs except for group and table.
Pages
{
"inputs": [
{
"type": "pages",
"label": {"en": "my pages"},
"tooltip": {"en":"my tooltip"},
"min_pages": 1,
"max_pages": 3,
"inputs": []
}
]
}
Note: the field min_pages
has a default value of 1
.
Note: the field max_pages
has a default value of undefined
.
Note: the array inputs
accepts all inputs except for pages.