SendNotification

Invia le notifiche push per i terminali mobili, i cui MetaQuotes IDs sono specificati nella scheda "Notifiche".

bool  SendNotification(
   string  text          // Testo della notifica
   );

Parametri

text

[in]   Il testo della notifica. La lunghezza del messaggio non deve superare i 255 caratteri.

Valore restituito

true se la notifica è stata inviata con successo dal terminale, in caso di fallimento restituisce false. Durante il controllo dopo una notifica push fallita, GetLastError() può restituire uno dei seguenti errori:

  • 4515 – ERR_NOTIFICATION_SEND_FAILED,
  • 4516 – ERR_NOTIFICATION_WRONG_PARAMETER,
  • 4517 – ERR_NOTIFICATION_WRONG_SETTINGS,
  • 4518 – ERR_NOTIFICATION_TOO_FREQUENT.

Nota

Severe restrizioni d'uso sono impostate per la funzione SendNotification(): non più di 2 chiamate al secondo e non più di 10 chiamate al minuto. Il monitoraggio della frequenza di utilizzo è dinamico. La funzione può essere disattivata in caso di violazione restrizione.

La funzione SendNotification() non funziona nel Tester di Strategia.

Esempio:

//+------------------------------------------------------------------+
//|                                             SendNotification.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com
#property version     "1.00"
 
#define   MESSAGE   "Test Message"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart(void)
  {
//--- controllare il permesso di inviare notifiche nel terminale
   if(!TerminalInfoInteger(TERMINAL_NOTIFICATIONS_ENABLED))
     {
      Print("Error. The client terminal does not have permission to send notifications");
      return;
     }
//--- inviare notifica
   ResetLastError();
   if(!SendNotification(MESSAGE))
      Print("SendNotification() failed. Error ",GetLastError());
  }