{"id":4825,"date":"2023-10-26T09:42:02","date_gmt":"2023-10-26T08:42:02","guid":{"rendered":"https:\/\/gdksoftware.com\/knowledgebase\/native-windows-notifications-with-delphi"},"modified":"2023-10-26T09:47:02","modified_gmt":"2023-10-26T08:47:02","slug":"notificacoes-nativas-do-windows-com-o-delphi","status":"publish","type":"knowledge","link":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi","title":{"rendered":"Notifica\u00e7\u00f5es nativas do Windows com o Delphi"},"content":{"rendered":"<p>O Windows 10 e 11 t\u00eam seu pr\u00f3prio sistema de notifica\u00e7\u00e3o. Em uma vers\u00e3o recente do Delphi, foi adicionado um componente chamado <code class=\"\" data-line=\"\">TNotificationCenter<\/code>. Adicione-o ao seu formul\u00e1rio e voc\u00ea poder\u00e1 exibir notifica\u00e7\u00f5es nativas do Windows.<\/p>\n<p><strong>Exemplo:<\/strong><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">const<\/span>\r\n  UPDATE_NOTIFICATION_ID <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">procedure<\/span> <span style=\"color: #bb0066; font-weight: bold;\">TForm1<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0066bb; font-weight: bold;\">Button1Click<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span>\r\n  Notification<span style=\"color: #333333;\">:<\/span> TNotification<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">begin<\/span>\r\n  Notification <span style=\"color: #333333;\">:=<\/span> NotificationCenter1<span style=\"color: #333333;\">.<\/span>CreateNotification<span style=\"color: #333333;\">;<\/span>\r\n\r\n  Notification<span style=\"color: #333333;\">.<\/span>Name <span style=\"color: #333333;\">:=<\/span> <span style=\"background-color: #fff0f0;\">'MyName'<\/span><span style=\"color: #333333;\">;<\/span>\r\n  Notification<span style=\"color: #333333;\">.<\/span>Number <span style=\"color: #333333;\">:=<\/span> UPDATE_NOTIFICATION_ID<span style=\"color: #333333;\">;<\/span>\r\n  Notification<span style=\"color: #333333;\">.<\/span>AlertBody <span style=\"color: #333333;\">:=<\/span> <span style=\"background-color: #fff0f0;\">'Update 2.3.5 is available, click here to install the update now.'<\/span><span style=\"color: #333333;\">;<\/span>\r\n  Notification<span style=\"color: #333333;\">.<\/span>EnableSound <span style=\"color: #333333;\">:=<\/span> <span style=\"color: #008800; font-weight: bold;\">False<\/span><span style=\"color: #333333;\">;<\/span>\r\n  Notification<span style=\"color: #333333;\">.<\/span>FireDate <span style=\"color: #333333;\">:=<\/span> <span style=\"color: #007020;\">Now<\/span><span style=\"color: #333333;\">;<\/span>\r\n  Notification<span style=\"color: #333333;\">.<\/span>HasAction <span style=\"color: #333333;\">:=<\/span> <span style=\"color: #008800; font-weight: bold;\">True<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n  NotificationCenter1<span style=\"color: #333333;\">.<\/span>PresentNotification(Notification)<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">end<\/span><span style=\"color: #333333;\">;<\/span>\r\n<\/pre>\n<\/div>\n<p><img decoding=\"async\" class=\"alignnone wp-image-4817 size-full\" src=\"https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification.png\" alt=\"\" width=\"436\" height=\"220\" srcset=\"https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification.png 436w, https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification-300x151.png 300w\" sizes=\"(max-width: 436px) 100vw, 436px\" \/><\/p>\n<p>Para tratar um clique de notifica\u00e7\u00e3o, implementamos <code class=\"\" data-line=\"\">OnReceiveLocalNotification<\/code><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">procedure<\/span> <span style=\"color: #bb0066; font-weight: bold;\">TForm1<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0066bb; font-weight: bold;\">NotificationCenter1ReceiveLocalNotification<\/span>(Sender<span style=\"color: #333333;\">:<\/span> <span style=\"color: #333399; font-weight: bold;\">TObject<\/span><span style=\"color: #333333;\">;<\/span> ANotification<span style=\"color: #333333;\">:<\/span> TNotification)<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">begin<\/span>\r\n  <span style=\"color: #008800; font-weight: bold;\">if<\/span> ANotification<span style=\"color: #333333;\">.<\/span>Number <span style=\"color: #333333;\">=<\/span> UPDATE_NOTIFICATION_ID  <span style=\"color: #008800; font-weight: bold;\">then<\/span>\r\n  <span style=\"color: #008800; font-weight: bold;\">begin<\/span>\r\n    InstallUpdate<span style=\"color: #333333;\">;<\/span>\r\n  <span style=\"color: #008800; font-weight: bold;\">end<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">end<\/span><span style=\"color: #333333;\">;<\/span>\r\n<\/pre>\n<\/div>\n<p>&nbsp;<br \/>\nPara agendar uma notifica\u00e7\u00e3o, usamos <code class=\"\" data-line=\"\">NotificationCenter.ScheduleNotification<\/code><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">procedure<\/span> <span style=\"color: #0066bb; font-weight: bold;\">ScheduleNotification<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">var<\/span>\r\n  Notification<span style=\"color: #333333;\">:<\/span> TNotification<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">begin<\/span>\r\n  Notification <span style=\"color: #333333;\">:=<\/span> NotificationCenter1<span style=\"color: #333333;\">.<\/span>CreateNotification<span style=\"color: #333333;\">;<\/span>\r\n  Notification<span style=\"color: #333333;\">.<\/span>AlertBody <span style=\"color: #333333;\">:=<\/span> <span style=\"background-color: #fff0f0;\">'It<\/span><span style=\"color: #666666; font-weight: bold; background-color: #fff0f0;\">''<\/span><span style=\"background-color: #fff0f0;\">s time to drink coffee :-)'<\/span><span style=\"color: #333333;\">;<\/span>\r\n  Notification<span style=\"color: #333333;\">.<\/span>FireDate  <span style=\"color: #333333;\">:=<\/span> IncHour(<span style=\"color: #007020;\">Now<\/span>)<span style=\"color: #333333;\">;<\/span>\r\n  \r\n  NotificationCenter1<span style=\"color: #333333;\">.<\/span>ScheduleNotification(Notification)<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">end<\/span><span style=\"color: #333333;\">;<\/span>\r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>e para cancelar a(s) notifica\u00e7\u00e3o(\u00f5es):<\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">procedure<\/span> <span style=\"color: #0066bb; font-weight: bold;\">CancelNotifications<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">begin<\/span>\r\n  <span style=\"color: #888888;\">\/\/ Cancel a specific one<\/span>\r\n  NotificationCenter1<span style=\"color: #333333;\">.<\/span>CancelNotification(<span style=\"background-color: #fff0f0;\">'MyName'<\/span>)<span style=\"color: #333333;\">;<\/span>\r\n  \r\n  <span style=\"color: #888888;\">\/\/ Cancel all notifications<\/span>\r\n  NotificationCenter1<span style=\"color: #333333;\">.<\/span>CancelAll<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">end<\/span><span style=\"color: #333333;\">;<\/span>\r\n<\/pre>\n<\/div>\n","protected":false},"featured_media":0,"parent":0,"template":"","class_list":["post-4825","knowledge","type-knowledge","status-publish","hentry","knowledge-category-arquivo-delphi"],"acf":{"author":1560,"type_hero":"compact","hero_image":4817,"hero_image_position":"","hero_title":"Native Windows Notifications with Delphi","hero_content":"","hero_link":null,"hero_show_h1":false},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Notifica\u00e7\u00f5es nativas do Windows com o Delphi - GDK Software<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Notifica\u00e7\u00f5es nativas do Windows com o Delphi\" \/>\n<meta property=\"og:description\" content=\"O Windows 10 e 11 t\u00eam seu pr\u00f3prio sistema de notifica\u00e7\u00e3o. Em uma vers\u00e3o recente do Delphi, foi adicionado um componente chamado TNotificationCenter. Adicione-o ao seu formul\u00e1rio e voc\u00ea poder\u00e1 exibir notifica\u00e7\u00f5es nativas do Windows. Exemplo: const UPDATE_NOTIFICATION_ID = 1; procedure TForm1.Button1Click; var Notification: TNotification; begin Notification := NotificationCenter1.CreateNotification; Notification.Name := &#039;MyName&#039;; Notification.Number := UPDATE_NOTIFICATION_ID; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi\" \/>\n<meta property=\"og:site_name\" content=\"GDK Software\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-26T08:47:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi\",\"url\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi\",\"name\":\"Notifica\u00e7\u00f5es nativas do Windows com o Delphi - GDK Software\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/gdksoftware.com\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/Delphi-notification.png\",\"datePublished\":\"2023-10-26T08:42:02+00:00\",\"dateModified\":\"2023-10-26T08:47:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi#primaryimage\",\"url\":\"https:\\\/\\\/gdksoftware.com\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/Delphi-notification.png\",\"contentUrl\":\"https:\\\/\\\/gdksoftware.com\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/Delphi-notification.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\\\/notificacoes-nativas-do-windows-com-o-delphi#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledgebase\",\"item\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/base-de-conhecimento\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Delphi\",\"item\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\\\/knowledgebase-category\\\/arquivo-delphi\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Notifica\u00e7\u00f5es nativas do Windows com o Delphi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br#website\",\"url\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br\",\"name\":\"GDK Software\",\"description\":\"Zet de stip op je horizon\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gdksoftware.com\\\/pt-br?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Notifica\u00e7\u00f5es nativas do Windows com o Delphi - GDK Software","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi","og_locale":"pt_BR","og_type":"article","og_title":"Notifica\u00e7\u00f5es nativas do Windows com o Delphi","og_description":"O Windows 10 e 11 t\u00eam seu pr\u00f3prio sistema de notifica\u00e7\u00e3o. Em uma vers\u00e3o recente do Delphi, foi adicionado um componente chamado TNotificationCenter. Adicione-o ao seu formul\u00e1rio e voc\u00ea poder\u00e1 exibir notifica\u00e7\u00f5es nativas do Windows. Exemplo: const UPDATE_NOTIFICATION_ID = 1; procedure TForm1.Button1Click; var Notification: TNotification; begin Notification := NotificationCenter1.CreateNotification; Notification.Name := 'MyName'; Notification.Number := UPDATE_NOTIFICATION_ID; [&hellip;]","og_url":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi","og_site_name":"GDK Software","article_modified_time":"2023-10-26T08:47:02+00:00","og_image":[{"url":"https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. tempo de leitura":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi","url":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi","name":"Notifica\u00e7\u00f5es nativas do Windows com o Delphi - GDK Software","isPartOf":{"@id":"https:\/\/gdksoftware.com\/pt-br#website"},"primaryImageOfPage":{"@id":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi#primaryimage"},"image":{"@id":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi#primaryimage"},"thumbnailUrl":"https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification.png","datePublished":"2023-10-26T08:42:02+00:00","dateModified":"2023-10-26T08:47:02+00:00","breadcrumb":{"@id":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi#primaryimage","url":"https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification.png","contentUrl":"https:\/\/gdksoftware.com\/wp-content\/uploads\/2023\/10\/Delphi-notification.png"},{"@type":"BreadcrumbList","@id":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento\/notificacoes-nativas-do-windows-com-o-delphi#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gdksoftware.com\/pt-br"},{"@type":"ListItem","position":2,"name":"Knowledgebase","item":"https:\/\/gdksoftware.com\/pt-br\/base-de-conhecimento"},{"@type":"ListItem","position":3,"name":"Delphi","item":"https:\/\/gdksoftware.com\/pt-br\/knowledgebase-category\/arquivo-delphi"},{"@type":"ListItem","position":4,"name":"Notifica\u00e7\u00f5es nativas do Windows com o Delphi"}]},{"@type":"WebSite","@id":"https:\/\/gdksoftware.com\/pt-br#website","url":"https:\/\/gdksoftware.com\/pt-br","name":"GDK Software","description":"Zet de stip op je horizon","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gdksoftware.com\/pt-br?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"}]}},"_links":{"self":[{"href":"https:\/\/gdksoftware.com\/pt-br\/wp-json\/wp\/v2\/knowledge\/4825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gdksoftware.com\/pt-br\/wp-json\/wp\/v2\/knowledge"}],"about":[{"href":"https:\/\/gdksoftware.com\/pt-br\/wp-json\/wp\/v2\/types\/knowledge"}],"acf:post":[{"embeddable":true,"href":"https:\/\/gdksoftware.com\/pt-br\/wp-json\/wp\/v2\/team\/1560"}],"wp:attachment":[{"href":"https:\/\/gdksoftware.com\/pt-br\/wp-json\/wp\/v2\/media?parent=4825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}