{"id":877,"date":"2018-02-18T22:35:54","date_gmt":"2018-02-18T19:35:54","guid":{"rendered":"http:\/\/enisnecipoglu.com\/?p=877"},"modified":"2018-05-14T10:06:39","modified_gmt":"2018-05-14T07:06:39","slug":"onesignal-ile-web-api-uzerinden-bildirim-gonderme","status":"publish","type":"post","link":"https:\/\/enisnecipoglu.com\/en\/onesignal-ile-web-api-uzerinden-bildirim-gonderme\/","title":{"rendered":"Send Push Notifications with OneSignal on Web API"},"content":{"rendered":"<p>Hi Everyone,<\/p>\n<p>Today I&#8217;m representing you a easy way to use OneSignal API with Asp.NET MVC project to send push notifications any platform with OneSignal.<\/p>\n<p>Firsly you can download <a href=\"https:\/\/github.com\/enisn\/OneSignal-PushNotification-from-Asp.NET-Web-API\">from here<\/a> the class library which created for OneSignal by me. Then add the library to your project, or build it and implement dll to your project ((!!! Do not forget to set your parameters in <strong>Configuration.cs <\/strong>before building a DLL !!!))<\/p>\n<h2><strong>MAKING CONFIGURATIONS<\/strong><\/h2>\n<p>Firstly go\u00a0<strong>Configuration.cs\u00a0<\/strong>and set your\u00a0<strong>App ID<\/strong> and\u00a0<strong>Rest API KEY<\/strong> paremeters.If you don&#8217;t know these parameters, go and sign in on OneSignal and go\u00a0<strong>SETTINGS <\/strong>from menu and click\u00a0<strong>KEYS &amp; IDs\u00a0<\/strong>tab. You can find these from here.<\/p>\n<hr \/>\n<p>You can find Visual Studio <strong>Project Template<\/strong> <a href=\"https:\/\/github.com\/enisn\/OneSignal-PushNotification-from-Asp.NET-Web-API\/raw\/master\/OneSignal.API.Template.zip\" rel=\"noopener\" target=\"_blank\">here<\/a><\/p>\n<hr \/>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-879\" src=\"http:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/02\/OneSignal_Appid.png\" alt=\"OneSignal Web API configuration, keys ids\" width=\"1200\" height=\"405\" srcset=\"https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/02\/OneSignal_Appid.png 1200w, https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/02\/OneSignal_Appid-300x101.png 300w, https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/02\/OneSignal_Appid-768x259.png 768w, https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/02\/OneSignal_Appid-1024x346.png 1024w, https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/02\/OneSignal_Appid-600x203.png 600w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>USING AND SEND PUSH NOTIFICATIONS<\/h2>\n<p>Go your API Controller or what you use to trigger. Just get an instance of Notification class and set your parameters. Some parameters is platform specific and I already added descriptions for theese ones. Set your parameters and don&#8217;t forget to set PlayerID, then use\u00a0<strong>Send()<\/strong> method to send this notification. Cool!<\/p>\n<div class=\"codecolorer-container csharp default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><div class=\"csharp codecolorer\">Notification myNotification <span class=\"sy0\">=<\/span> <span class=\"kw3\">new<\/span> Notification<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\nmyNotification<span class=\"sy0\">.<\/span><span class=\"me1\">contents<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;HEELO FROM PUSH NOTIFICATION!&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\nmyNotification<span class=\"sy0\">.<\/span><span class=\"me1\">small_icon<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">&quot;icon.png&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\nmyNotification<span class=\"sy0\">.<\/span><span class=\"me1\">include_player_ids<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw3\">new<\/span> List <span class=\"br0\">&#123;<\/span> <span class=\"st0\">&quot;OneSignal_playerid_fordevice&quot;<\/span>,<span class=\"st0\">&quot;Another_onesignal_playerid&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\nmyNotification<span class=\"sy0\">.<\/span><span class=\"me1\">Send<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>You can download Class Library:<\/p>\n<p><a href=\"https:\/\/github.com\/enisn\/OneSignal-PushNotification-from-Asp.NET-Web-API\">OneSignal PushNotification Library<\/a><\/p>\n<blockquote>\n<h2>Possible Mistakes<\/h2>\n<ul>\n<li>Install v.10.0.3 or newer version of Newtonsoft.Json to your main project.<\/li>\n<li>Do not forget set your App ID and RestAPI KEY in Configuration.cs<\/li>\n<\/ul>\n<\/blockquote>\n<p><\/p>","protected":false},"excerpt":{"rendered":"Hi Everyone, Today I&#8217;m representing you a easy way to use OneSignal API with Asp.NET MVC project to send push notifications any platform with OneSignal. Firsly you can download from here the class library which created for OneSignal by me. Then add the library to your project, or build it and implement dll to your project ((!!! Do not forget to set your parameters in Configuration.cs before building a DLL !!!)) MAKING CONFIGURATIONS Firstly go\u00a0Configuration.cs\u00a0and set your\u00a0App ID and\u00a0Rest API KEY paremeters.If you don&#8217;t know these parameters, go and sign in on OneSignal and go\u00a0SETTINGS from menu and click\u00a0KEYS &amp; IDs\u00a0tab. You can find these from here. You can find Visual Studio Project Template here &nbsp; USING AND SEND PUSH NOTIFICATIONS Go your API Controller or what you use to trigger. Just get an instance of Notification class and set your parameters. Some parameters is platform specific and I already added descriptions for theese ones. Set your parameters and don&#8217;t forget to set PlayerID, then use\u00a0Send() method to send this notification. Cool! Notification myNotification = new Notification&#40;&#41;; myNotification.contents = &quot;HEELO FROM PUSH NOTIFICATION!&quot;; myNotification.small_icon = &quot;icon.png&quot;; myNotification.include_player_ids = new List &#123; &quot;OneSignal_playerid_fordevice&quot;,&quot;Another_onesignal_playerid&quot; &#125;; myNotification.Send&#40;&#41;; You can download Class Library: OneSignal PushNotification Library Possible Mistakes Install v.10.0.3 or newer version of Newtonsoft.Json to your main project. Do not forget set your App ID and RestAPI KEY in Configuration.cs","protected":false},"author":1,"featured_media":879,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,6],"tags":[39,35,37,36,38],"_links":{"self":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts\/877"}],"collection":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/comments?post=877"}],"version-history":[{"count":3,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts\/877\/revisions"}],"predecessor-version":[{"id":1018,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts\/877\/revisions\/1018"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/media\/879"}],"wp:attachment":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/media?parent=877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/categories?post=877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/tags?post=877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}