Push notifications


Push notifikácie sú podporované na zariadeniach s Androidom a iOS.

Zobrazenie notifikácie na zariadení (iOS/Android):

Pre príjem notifikácií musí používateľ povoliť túto funkcionalitu pre aplikáciu ERPIO App na danom zariadení (nastavenia sa rôznia podľa platfomy a konkrétnej verzie systému).

Nastavenie notifikácií

Na odosielanie sa používa akcia typu pumpa s preddefinovaným nastavením.

Postup:

1. Vytvorenie dátového zdroja (Data source)

Je potrebné vytvoriť dátový zdroj nad údajmi, ktoré sa majú posielať vo forme notifikácií. Dátový zdroj misí mať nastavený Command Type na Plain Text. Musí obsahovať:

  • Príjemcovia – čiarkou oddelený zoznam e-mailových adries – prihlasovacích mien používateľov E1
  • Titulok notifikácie
  • Telo správy

V ideálnom prípade by dátový zdroj mal vrátiť údaje pre odoslanie a zároveň ich označiť ako odoslané. Je vhodné limitovať počet naraz (v jednej iterácii) odosielaných notifikácií. Príklad príkazu:

DECLARE @TempNotificationsTable TABLE
(
  Title nvarchar(255), 
  Body nvarchar(max),
  Recipients nvarchar(255)
)

UPDATE TOP (20) TabE1PushNotifications  
SET SentOn = GETDATE()   
OUTPUT inserted.Title, inserted.Body, inserted.Recipients INTO @TempNotificationsTable
WHERE SentOn IS NULL

SELECT DISTINCT Title, Body, Recipients FROM @TempNotificationsTable

Príklad vrátených údajov:

2. Vytvorenie sady (Set)

Je potrebné vytvoriť z dátového zdroja set, kde budú minimálnie tieto 3 vyžadované stĺpce.

3. Vytvorenie akcie nad sadou

Pridať novú akciu v danom set-e. V akcii v hornej časti je vyberač pre predvolené nastavenie pre push notifikácie. Vyberiete _notifyservice a kliknete na tlačidlo so šípkou dole, predvolené nastavenia sa aplikujú do akcie.

V spodnej časti, v parametroch sú predvyplnené dostupné parametre, do ktorých priradíme stĺpce zo set-u

Nezabudneme akciu označiť ako aktívnu a možeme ju uložiť.

4. Pravidelné odosielanie notifikácií

Pre pravidelné odosielanie notifikácií je potrebné vytvoriť akciu typu Automatization. V novej akcii sa vyberá typ Automatization, v spodnej časti sa zobrazí editor akcií, vo vyberači Action auto items vyberieme našu akciu typu pumpa z predchádzajúcich krokov a klikneme na tlačidlo Add (v automatization akcii je možné mať viacero akcií, ktoré sa majú vykonať v danom momente podľa poradia).

Akciu uložíme. Následne je potrebné nastaviť plánovač (Scheduler) pre túto akciu, aby sa spúštala v nastavenom intervale. Plánovač nájdete na Dashboarde:

Dáte vytvoriť nový, pomenujete ho, nastavíte ho ako aktívny. Nastavíte interval, v spodnej časti sa vyberie a pridá príslušná automatization akcia. Ak napr. chcem, aby notifikácie sa posielali každé 3 minúty, tak nastavenia budú nasledovné:

Plánovač uložíme.

Custom:

{
  "definitions": {
    "Action": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "action": {
          "type": [
            "string",
            "null"
          ]
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "icon": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "action",
        "title",
        "icon"
      ]
    },
    "AndroidConfig": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "collapse_key": {
          "type": [
            "string",
            "null"
          ]
        },
        "restricted_package_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "notification": {
          "$ref": "#/definitions/AndroidNotification"
        },
        "fcm_options": {
          "$ref": "#/definitions/AndroidFcmOptions"
        },
        "priority": {
          "type": [
            "string",
            "null"
          ]
        },
        "ttl": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "collapse_key",
        "restricted_package_name",
        "notification",
        "fcm_options",
        "priority",
        "ttl"
      ]
    },
    "AndroidFcmOptions": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "analytics_label": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "analytics_label"
      ]
    },
    "AndroidNotification": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "body": {
          "type": [
            "string",
            "null"
          ]
        },
        "icon": {
          "type": [
            "string",
            "null"
          ]
        },
        "color": {
          "type": [
            "string",
            "null"
          ]
        },
        "sound": {
          "type": [
            "string",
            "null"
          ]
        },
        "tag": {
          "type": [
            "string",
            "null"
          ]
        },
        "image": {
          "type": [
            "string",
            "null"
          ]
        },
        "click_action": {
          "type": [
            "string",
            "null"
          ]
        },
        "title_loc_key": {
          "type": [
            "string",
            "null"
          ]
        },
        "title_loc_args": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "body_loc_key": {
          "type": [
            "string",
            "null"
          ]
        },
        "body_loc_args": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "channel_id": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "title",
        "body",
        "icon",
        "color",
        "sound",
        "tag",
        "image",
        "click_action",
        "title_loc_key",
        "title_loc_args",
        "body_loc_key",
        "body_loc_args",
        "channel_id"
      ]
    },
    "ApnsConfig": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "fcm_options": {
          "$ref": "#/definitions/ApnsFcmOptions"
        },
        "payload": {
          "$ref": "#/definitions/ApnsPayload"
        }
      },
      "required": [
        "fcm_options",
        "payload"
      ]
    },
    "ApnsFcmOptions": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "analytics_label": {
          "type": [
            "string",
            "null"
          ]
        },
        "image": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "analytics_label",
        "image"
      ]
    },
    "ApnsPayload": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "aps": {
          "$ref": "#/definitions/Aps"
        }
      },
      "required": [
        "aps"
      ]
    },
    "Aps": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "badge": {
          "type": [
            "integer",
            "null"
          ]
        },
        "category": {
          "type": [
            "string",
            "null"
          ]
        },
        "thread-id": {
          "type": [
            "string",
            "null"
          ]
        },
        "alert": {},
        "sound": {},
        "content-available": {
          "type": [
            "integer",
            "null"
          ]
        },
        "mutable-content": {
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "required": [
        "badge",
        "category",
        "thread-id",
        "alert",
        "sound",
        "content-available",
        "mutable-content"
      ]
    },
    "FcmOptions": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "analytics_label": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "analytics_label"
      ]
    },
    "Notification": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "body": {
          "type": [
            "string",
            "null"
          ]
        },
        "image": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "title",
        "body",
        "image"
      ]
    },
    "WebpushConfig": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "notification": {
          "$ref": "#/definitions/WebpushNotification"
        },
        "fcm_options": {
          "$ref": "#/definitions/WebpushFcmOptions"
        }
      },
      "required": [
        "notification",
        "fcm_options"
      ]
    },
    "WebpushFcmOptions": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "link": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "link"
      ]
    },
    "WebpushNotification": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "body": {
          "type": [
            "string",
            "null"
          ]
        },
        "icon": {
          "type": [
            "string",
            "null"
          ]
        },
        "badge": {
          "type": [
            "string",
            "null"
          ]
        },
        "image": {
          "type": [
            "string",
            "null"
          ]
        },
        "lang": {
          "type": [
            "string",
            "null"
          ]
        },
        "renotify": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "requireInteraction": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "silent": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "tag": {
          "type": [
            "string",
            "null"
          ]
        },
        "timestamp": {
          "type": [
            "integer",
            "null"
          ]
        },
        "vibrate": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "integer"
          }
        },
        "actions": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/Action"
          }
        },
        "dir": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "title",
        "body",
        "icon",
        "badge",
        "image",
        "lang",
        "renotify",
        "requireInteraction",
        "silent",
        "tag",
        "timestamp",
        "vibrate",
        "actions",
        "dir"
      ]
    }
  },
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "token": {
      "type": [
        "string",
        "null"
      ]
    },
    "condition": {
      "type": [
        "string",
        "null"
      ]
    },
    "notification": {
      "$ref": "#/definitions/Notification"
    },
    "android": {
      "$ref": "#/definitions/AndroidConfig"
    },
    "webpush": {
      "$ref": "#/definitions/WebpushConfig"
    },
    "apns": {
      "$ref": "#/definitions/ApnsConfig"
    },
    "fcm_options": {
      "$ref": "#/definitions/FcmOptions"
    },
    "topic": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "token",
    "condition",
    "notification",
    "android",
    "webpush",
    "apns",
    "fcm_options",
    "topic"
  ]
}