Skip to content

In-App Content

You might want to define a content to be shown inside you mobile application in case the user taps on the notification.

Plugins and Actions

The reaction_plugin and reaction_action fields tell NearIT what kind of content you want to deliver, you can choose between different alternatives:

What Plugin Action Required Bundle
Simple Notification simple-notification simple_notification null
Notification + Content content-notification show_content Content
Notification + Feedback feedbacks ask_feedback Feedback
Notification + Coupon coupon-blaster show_coupon Coupon
Notification + Custom JSON json-sender deliver_json JSON

Bundle and Bundle_ID

Every NearIT in-app content can be used in different recipes and is saved as a separated entity. While creating a recipe with our API, you can choose to:

  • tell NearIT to use an existing content using the bundle_id attribute
  • define a new content using the bundle attribute

Quick example: push recipe with a new content

This API call will send a notification immediately, on tap the users will receive a standard NearIT content made of:

  • a title
  • an image
  • an html text
  • an action button

Every content field is optional.

POST https://api.nearit.com/recipes

{
  "data": {
    "type": "recipes",
    "attributes": {
      "owner_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "app_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "name": "push with content",
      "state_event": "finalize",
      "notification_translations": {
        "en": {
          "body": "Hello World"
        },
        "it": {
          "body": "Ciao Mondo"
        }
      },
      "default_language": "en",
      "operation_plugin_id": "congrego",
      "operation_action_id": "evaluate_segment",
      "operation_bundle": {
        "owner_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "app_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
      },
      "reaction_plugin_id": "content-notification",
      "reaction_action_id": "show_content",
      "reaction_bundle": {
        "owner_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "app_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "default_language":"en",
            "title_translations":{  
                "en":"Lorem Ipsum",
                "it":"Lorem Ipsum"
            },
            "content_translations":{
                "en":"<p>Lorem ipsum dolor sit amet, consectetur <b>adipiscing</b> elit. Curabitur vestibulum eleifend sapien in pellentesque. Nunc tempor posuere est nec fermentum. </p>",
                "it":"<p>Lorem ipsum dolor sit amet, consectetur <b>adipiscing</b> elit. Curabitur vestibulum eleifend sapien in pellentesque. Nunc tempor posuere est nec fermentum. </p>"
            },
            "link_translations":{  
                "en":{  
                    "label":"NearIT website",
                    "url":"https://www.nearit.com/"
                },
                "it":{  
                    "label":"sito NearIT",
                    "url":"https://www.nearit.com/it/"
                }
            },
            "image_ids_translations":{  
                "en":[  
                    "67d7cdc0-e06c-4117-9bf7-1f5db6711dac"
                ],
                "it":[  
                    "67d7cdc0-e06c-4117-9bf7-1f5db6711dac"
                ]
            }
      },
      "pulse_plugin_id": "push-machine",
      "pulse_action_id": "send_push",
      "pulse_bundle": {
        "owner_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "app_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
      }
    }
  }
}

Upload an image to NearIT

The content of the previous example includes an image.
If you want to use an image in your contents you will need to upload it as BASE64:

POST https://api.nearit.com/uploads

{
    "data": {
        "attributes":
        {
            "name":"my_new_image.png",
            "image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDgAAAGFCAYAAAAYfEODAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6==\n",
            "creator_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
            "app_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
        }
    }
}

The server response will include your image ID, that can be used inside your recipes:

{
  "data": {
    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    "type": "uploads",
    "attributes": {
      "name": "in",
      "upload": {
        "url": "...",
        "square_300": {
          "url": "..."
        }
      },
      "app_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "creator_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "created_at": "2017-11-15T09:44:18.214Z",
      "updated_at": "2017-11-15T09:44:18.214Z"
    },
    "meta": {
      "processing": true
    }
  }
}

Complete Reference

For more details about our contents, please look at: