<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anıl Dursun ŞENEL on Medium]]></title>
        <description><![CDATA[Stories by Anıl Dursun ŞENEL on Medium]]></description>
        <link>https://medium.com/@anildursunsenel?source=rss-464f0f57ad7c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DrJYhIEMvnbqUeur</url>
            <title>Stories by Anıl Dursun ŞENEL on Medium</title>
            <link>https://medium.com/@anildursunsenel?source=rss-464f0f57ad7c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:49:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anildursunsenel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Crafting Trustworthy Notifications: How to Implement Server-Side VAPID WebPush with AdsPush]]></title>
            <link>https://medium.com/adessoturkey/crafting-trustworthy-notifications-how-to-implement-server-side-vapid-webpush-with-adspush-182144105678?source=rss-464f0f57ad7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/182144105678</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[server-side-notification]]></category>
            <category><![CDATA[vapid]]></category>
            <category><![CDATA[push-ads]]></category>
            <dc:creator><![CDATA[Anıl Dursun ŞENEL]]></dc:creator>
            <pubDate>Tue, 29 Aug 2023 21:59:40 GMT</pubDate>
            <atom:updated>2023-10-02T06:37:12.905Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B873gcLMbY_dIx6tHdjzFw.png" /></figure><p>In the dynamic landscape of app development, notifications play a pivotal role in connecting with users. However, with increased connectivity comes the need for heightened security and trust. This is where the innovation of VAPID (Voluntary Application Server Identification) with WebPush steps in. In this article, we’ll embark on a journey to understand and implement server-side VAPID WebPush using the AdsPush library. Through practical insights and examples, we’ll explore how this technique enhances the delivery of notifications while ensuring authenticity and security.</p><h3>Unveiling the Essence of VAPID</h3><p>Before we dive into implementation, let’s grasp the concept of VAPID. VAPID, or Voluntary Application Server Identification, introduces a standardized way to authenticate your server’s identity to push services. This is achieved by cryptographically signing your push messages, allowing the recipient’s device to verify the source of the notification. In essence, VAPID enhances both the security and trustworthiness of your notifications, fostering a more secure environment for user interaction.</p><h3>Understanding AdsPush: Your Ally in Push Notifications</h3><p>As we delve into the world of server-side VAPID WebPush, let’s meet your partner in this journey — AdsPush. An open-source NuGet package, AdsPush serves as your bridge to sending server-side notifications while ensuring ease of use and robust functionality. With full support for APNS, FCM, and VAPID WebPush, AdsPush offers a comprehensive solution for your push notification needs. Its abstraction simplifies complex processes, making it accessible to developers across varying skill levels.</p><p>In the upcoming sections, we’ll transition from theory to practice, exploring how to integrate VAPID WebPush using AdsPush. We’ll navigate through a sample JavaScript WebPush client project and demonstrate how AdsPush streamlines the process of incorporating this technique into your application. By the end of this journey, you’ll be well-equipped to implement server-side VAPID WebPush, enhancing both the engagement and security of your app.</p><p>In this article, I’ll be skipping the installation and configuration sections of AdsPush for brevity. If you’re looking for more detailed information about this aspect, you can refer to the following dedicated article.</p><blockquote><a href="https://medium.com/adessoturkey/adspush-sending-server-side-push-notifications-using-net-92a7392d1a53">AdsPush: Sending Server-Side Push Notifications Using .NET</a></blockquote><h3>Let’s Jomb the Code</h3><h4>Generating VAPID Keys Using Bash Commands</h4><p>Before delving into the implementation, let’s create the essential VAPID keys: the public and private keys. These keys play a crucial role in authenticating your server and ensuring secure communication. Here’s how you can generate them using bash commands:</p><p>Public Key Generation:</p><pre>openssl ecparam -name prime256v1 -genkey -noout -out vapid_private.pem<br>openssl ec -in vapid_private.pem -pubout -out vapid_public.pem</pre><p><strong>Private Key Generation:</strong></p><pre>openssl ecparam -name prime256v1 -genkey -noout -out vapid_private.pem</pre><p>After running these commands, you’ll have the vapid_private.pem file containing your private key, and the vapid_public.pem file containing your public key.</p><p>Remember, safeguard these keys as they grant access to your server. Now that we have our keys ready, let’s seamlessly integrate VAPID WebPush with AdsPush.</p><p>In the next section, we’ll explore how to incorporate these keys into your <strong>AdsPush</strong> implementation and elevate the security of your notification delivery.</p><blockquote>Additionally, if you prefer a code-side approach for generating keys, AdsPush offers a convenient solution. You can utilize the VapidHelper.GenerateVapidKeys() method provided by AdsPush to dynamically generate your VAPID keys directly within your codebase. This method streamlines the process, eliminating the need for external tools or scripts. By invoking this method, you can programmatically generate the required VAPID public and private keys, enhancing the efficiency of your implementation.</blockquote><h4>Configuring Sample Client App</h4><p>As we venture into configuring our sample client app, it’s essential to understand the role of Service Workers in modern web development. A Service Worker is a background JavaScript script that empowers you to manage network requests, caching, and more, contributing to enhanced user experiences. By incorporating Service Workers into your app, you can enable powerful features like push notifications and offline access.</p><p>With this foundation in place, let’s proceed to set up the sample client app with a Service Worker. We’ll be utilizing the Service Worker to facilitate the VAPID-secured push notifications using the keys we generated earlier. This integration will pave the way for secure and seamless communication between your server and the user’s device.</p><p>In the upcoming steps, we’ll walk through the process of integrating the Service Worker, and later, we’ll delve into AdsPush integration for a comprehensive push notification solution. Let’s get started!</p><p>And now, let’s dive into the code! Below, you’ll find the sample Service Worker implementation that sets the stage for our VAPID-enabled push notifications. Take a moment to explore the intricacies of this essential script.</p><p>But that’s not all — next up, we have our sample HTML page. This page requests the user’s notification permission, a pivotal step in establishing a seamless communication channel. Let’s move on to this crucial part</p><pre>self.addEventListener(&quot;push&quot;, (event) =&gt; {<br>  if (!(self.Notification &amp;&amp; self.Notification.permission === &quot;granted&quot;)) {<br>    return;<br>  }<br><br>  const data = event.data?.json() ?? {};<br>  const icon = &quot;icon.png&quot;;<br><br>  const options = {<br>    lang: data.lang || &quot;en-US&quot;,<br>    title: data.title,<br>    body: data.message,<br>    tag: data.tag,<br>    silent: data.silent,<br>    image: data.image,<br>    vibrate: [200, 100, 200],<br>    actions: data.actions || [],<br>    icon,<br>    data: {<br>      url: data.click_action<br>    }<br>  };<br><br>  //do your operations<br>  if (options.silent)<br>    return;<br>  event.waitUntil(self.registration.showNotification(data.title, options));<br><br>});<br><br>self.addEventListener(&#39;notificationclick&#39;, function (event) {<br>  event.notification.close(); // Bildirimi kapat<br>  if (clients.openWindow &amp;&amp; event.notification.data.url) {<br>    event.waitUntil(clients.openWindow(event.notification.data.url));<br>  }<br>});<br><br>self.addEventListener(&#39;install&#39;, function (event) {<br>  self.skipWaiting();<br>});<br><br>self.addEventListener(&#39;activate&#39;, function (event) {<br>  event.waitUntil(clients.claim()); // Hemen etkinleşmesini sağla<br>});</pre><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>  &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt;<br>  &lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black-translucent&quot;&gt;<br>  &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icon.png&quot;&gt;<br>  &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;180x180&quot; href=&quot;icon-180.png&quot;&gt;<br>  &lt;link rel=&quot;manifest&quot; href=&quot;manifest.json&quot;&gt;<br>  &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;<br>        integrity=&quot;sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9&quot; crossorigin=&quot;anonymous&quot;&gt;<br>  &lt;title&gt;AdsPush Vapid Client Test&lt;/title&gt;<br><br>&lt;/head&gt;<br>&lt;body class=&quot;bg-dark&quot; data-bs-theme=&quot;dark&quot;&gt;<br>&lt;div class=&quot;container my-5&quot;&gt;<br>  &lt;h1 class=&quot;mb-4&quot;&gt;AdsPush Sample App&lt;/h1&gt;<br>  &lt;button id=&quot;subscribeButton&quot; class=&quot;btn btn-primary mb-3&quot;&gt;Abone Ol&lt;/button&gt;<br>  &lt;div class=&quot;mb-3&quot;&gt;<br>    &lt;label for=&quot;endpoint&quot; class=&quot;form-label&quot;&gt;Endpoint:&lt;/label&gt;<br>    &lt;div class=&quot;input-group&quot;&gt;<br>      &lt;textarea id=&quot;endpoint&quot; rows=&quot;3&quot; readonly class=&quot;form-control&quot;&gt;&lt;/textarea&gt;<br>      &lt;button class=&quot;btn btn-outline-primary&quot; onclick=&quot;copyContent(&#39;endpoint&#39;)&quot;&gt;Kopyala&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;mb-3&quot;&gt;<br>    &lt;label for=&quot;p256dh&quot; class=&quot;form-label&quot;&gt;p256dh:&lt;/label&gt;<br>    &lt;div class=&quot;input-group&quot;&gt;<br>      &lt;textarea id=&quot;p256dh&quot; rows=&quot;3&quot; readonly class=&quot;form-control&quot;&gt;&lt;/textarea&gt;<br>      &lt;button class=&quot;btn btn-outline-primary&quot; onclick=&quot;copyContent(&#39;p256dh&#39;)&quot;&gt;Kopyala&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>  &lt;div class=&quot;mb-3&quot;&gt;<br>    &lt;label for=&quot;auth&quot; class=&quot;form-label&quot;&gt;auth:&lt;/label&gt;<br>    &lt;div class=&quot;input-group&quot;&gt;<br>      &lt;textarea id=&quot;auth&quot; rows=&quot;3&quot; readonly class=&quot;form-control&quot;&gt;&lt;/textarea&gt;<br>      &lt;button class=&quot;btn btn-outline-primary&quot; onclick=&quot;copyContent(&#39;auth&#39;)&quot;&gt;Kopyala&lt;/button&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;<br>&lt;script&gt;<br>  document.querySelector(&quot;#subscribeButton&quot;).addEventListener(&quot;click&quot;, async () =&gt; {<br>    try {<br>      const permission = await Notification.requestPermission();<br>      if (permission !== &#39;granted&#39;) {<br>        alert(&quot;Permission denied&quot;)<br>        return;<br>      }<br>      const subscription = await subscribeUserToPush();<br>      sendSubscriptionToServer(subscription);<br>    } catch (error) {<br>      alert(&quot;Permission was not granted or subscription failed&quot;)<br>      console.error(&#39;Permission was not granted or subscription failed:&#39;, error);<br>    }<br>  });<br><br>  async function subscribeUserToPush() {<br>    const registration = await navigator.serviceWorker.register(&#39;service-worker.js&#39;);<br>    const subscribeOptions = {<br>      userVisibleOnly: true,<br>      // Replace &#39;your_public_key_here&#39; with your actual public key,<br>      // and make sure not to include the &#39;begin&#39; and &#39;end&#39; tags.<br>      applicationServerKey: urlBase64ToUint8Array(&#39;your_public_key_here&#39;)<br>    };<br>    return registration.pushManager.subscribe(subscribeOptions);<br>  }<br><br>  function sendSubscriptionToServer(subscription) {<br>    console.log(JSON.stringify(subscription));<br>    let subObj = JSON.parse(JSON.stringify(subscription))<br>    document.querySelector(&quot;#endpoint&quot;).value = subObj.endpoint;<br>    document.querySelector(&quot;#p256dh&quot;).value = subObj.keys.p256dh;<br>    document.querySelector(&quot;#auth&quot;).value = subObj.keys.auth;<br>    // Send subObj to your server here.<br>  }<br><br>  function urlBase64ToUint8Array(base64String) {<br>    const padding = &#39;=&#39;.repeat((4 - base64String.length % 4) % 4);<br>    const base64 = (base64String + padding)<br>      .replace(/-/g, &#39;+&#39;)<br>      .replace(/_/g, &#39;/&#39;);<br>    const rawData = window.atob(base64);<br>    const outputArray = new Uint8Array(rawData.length);<br>    for (let i = 0; i &lt; rawData.length; ++i) {<br>      outputArray[i] = rawData.charCodeAt(i);<br>    }<br>    return outputArray;<br>  }<br><br>  function copyContent(elementId) {<br>    const element = document.getElementById(elementId);<br>    element.select();<br>    document.execCommand(&quot;copy&quot;);<br>  }<br><br>&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><blockquote><a href="https://github.com/adessoTurkey-dotNET/AdsPush/blob/main/samples/AdsPushSample.VapidClient/index.html">You can access full code from here</a></blockquote><h4>Using AdsPush</h4><pre>// Configure VAPID settings for AdsPush<br>var vapidSettings = new AdsPushVapidSettings()<br>{<br>    // Replace with your actual VAPID public key<br>    PublicKey = &quot;your_public_key_here&quot;,<br><br>    // Replace with your actual VAPID private key<br>    PrivateKey = &quot;your_private_key_here&quot;<br>};<br><br>var sender = builder<br>    .ConfigureVapid(vapidSettings)<br>    .BuildSender();<br><br>//Comming from client.<br>string<br>    endpoint = &quot;https://fcm.googleapis.com/fcm/send/cIo6QJ4MMtQ:APA91bEGHCpZdHaUS7otb5_xU1zNWe6TAqria9phFm7M_9ZIiEyr0vXj3gRHbeIJMYvp2-SAVbgNrVvl7uBvU_VTLpIA0CLBcmqXuuEktGr0U4LVLvwWBibO68spJk7D-lr8R9zPyAXE&quot;,<br>    p256dh = &quot;BIjydse4Rij892SJN10xx1qbxDM6GrYXSfg7TGu90CVM1WmlTYzn_79psRqseyWdER969LGLjZmnXIhHPaKTyGE&quot;,<br>    auth = &quot;TkLGLzFeUU3C9SJJN6dLAA&quot;;<br><br>var subscription = VapidSubscription.FromParameters(endpoint, p256dh, auth);<br>//Sending basic notification<br>var basicPayload = new AdsPushBasicSendPayload()<br>{<br>    Title = AdsPushText.CreateUsingString(&quot;test&quot;),<br>    Detail = AdsPushText.CreateUsingString(&quot;detail&quot;),<br>    Badge = 52,<br>    Sound = &quot;default&quot;,<br>    Parameters = new Dictionary&lt;string, object&gt;()<br>    {<br>        {<br>            &quot;pushParam1&quot;, &quot;value1&quot;<br>        },<br>        {<br>            &quot;pushParam2&quot;, &quot;value2&quot;<br>        },<br>    }<br>};<br><br>await sender.BasicSendAsync(<br>    AdsPushTarget.BrowserAndPwa,<br>    subscription.ToAdsPushToken(),<br>    basicPayload);<br><br>//Accessing full patform option<br>var vapidResult = await sender<br>    .GetVapidSender()<br>    .SendAsync(<br>        subscription,<br>        new VapidRequest()<br>        {<br>            Title = &quot;&quot;,<br>            Badge = &quot;&quot;,<br>            Message = &quot;&quot;,<br>            Sound = &quot;&quot;,<br>            Icon = &quot;&quot;,<br>            Image = &quot;&quot;,<br>            Language = &quot;&quot;,<br>            Silent = false,<br>            Tag = &quot;&quot;,<br>            ClickAction = &quot;&quot;,<br>            VibratePattern = &quot;&quot;,<br>            Data = new Dictionary&lt;string, string&gt;()<br>            {<br>                {<br>                    &quot;param1&quot;, &quot;value1&quot;<br>                }<br>            }<br>        });</pre><h3>Conclusion</h3><p>In closing, this article has introduced the powerful realm of server-side VAPID WebPush with the invaluable aid of AdsPush. By seamlessly integrating VAPID authentication into your notifications, you’ve fortified the security and trustworthiness of your communication. AdsPush, an open-source gem, extends an accessible bridge between your applications and users across diverse platforms, empowering you to forge engaging and secure user experiences.</p><p>As an open-source tool, AdsPush fosters a collaborative environment. It not only simplifies complex processes but also invites contributions from the developer community. This synergy propels the continuous evolution of this library, ensuring that you’re equipped with cutting-edge solutions for your push notification needs. The journey of exploration and implementation continues, and with AdsPush, you’re well-positioned to make notifications a standout feature of your applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=182144105678" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adessoturkey/crafting-trustworthy-notifications-how-to-implement-server-side-vapid-webpush-with-adspush-182144105678">Crafting Trustworthy Notifications: How to Implement Server-Side VAPID WebPush with AdsPush</a> was originally published in <a href="https://medium.com/adessoturkey">adessoTurkey</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AdsPush: Sending Server-Side Push Notifications Using .NET]]></title>
            <link>https://medium.com/adessoturkey/adspush-sending-server-side-push-notifications-using-net-92a7392d1a53?source=rss-464f0f57ad7c------2</link>
            <guid isPermaLink="false">https://medium.com/p/92a7392d1a53</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[apn]]></category>
            <category><![CDATA[push-ads]]></category>
            <category><![CDATA[nuget]]></category>
            <dc:creator><![CDATA[Anıl Dursun ŞENEL]]></dc:creator>
            <pubDate>Fri, 11 Aug 2023 18:21:48 GMT</pubDate>
            <atom:updated>2023-08-21T10:38:41.909Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>AdsPush: Sending Server-Side Push Notifications Using .NET</strong></h3><p>In the realm of modern app development, where engagement is the heartbeat of success, the art of seamless communication has taken center stage. Picture the impact of reaching out to your users with timely updates, personalized content, or important announcements, as they go about their digital journey. This is where the power of AdsPush comes into play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U2o6BF4I7-lvcq94CNMgpQ.png" /></figure><h3>What is AdsPush?</h3><p>AdsPush is an open-source NuGet package developed with .NET. This package is designed to manage and send push notifications on the server side. It particularly stands out by offering support for both APNS (Apple Push Notification Service) and FCM (Firebase Cloud Messaging), ensuring seamless integration with various platforms. It distinguishes itself with high-level abstraction, ease of use, and full support for advanced usage scenarios.</p><h3>How to Use It?</h3><p>Using AdsPush is straightforward and allows for rapid integration. Here are the basic steps:</p><h4>Step 1: Add the NuGet Package to Your Project</h4><p>Add the AdsPush package to your project via NuGet Package Manager or .NET CLI:</p><pre>dotnet add package AdsPush</pre><p>or</p><pre>Install-Package AdsPush</pre><h4>Step 2: Configure The Services</h4><p>You have two easy options to be able configure AdsPush</p><p>1. <strong>Using Microsoft Dependency Injection (recommended)</strong></p><ul><li>Using default configuration provider (Microsoft Options Pattern)</li><li>Using custom configuration provider.</li></ul><p>Microsoft Dependency Injection is Microsoft’s IoC library that comes with .NET Core. AdsPush supports using MDI to manage your push configuration and sending operations.</p><p>If you’re sing .NET 6 or newer version in Program.cs</p><pre><br>using AdsPush.Extensions;<br><br>var builder = WebApplication.CreateBuilder(args);<br>//Option 1:From configuration<br>builder.Services.AddAdsPush(this.Configuration);<br>    <br>//Option 2:From Action<br>builder.Services.AddAdsPush(options =&gt; <br>{<br>    //Your configurations<br>});<br>    <br>//Option 3:From custom provider that is implementation of IAdsPushConfigurationProvider interface.<br>builder.Services.AddAdsPush&lt;MyProvider&gt;();</pre><p>If you’re sing .NET 5 or any .NET Core version in Startup.cs</p><pre>using AdsPush.Extensions;<br>...<br><br> public override void ConfigureServices(IServiceCollection services)<br> {<br>    //your code...<br>    <br>    //Option 1:From configuration<br>    services.AddAdsPush(this.Configuration);<br>    <br>    //Option 2:From Action<br>    services.AddAdsPush(options =&gt; <br>    {<br>        //Your configurations<br>    });<br>    <br>    //Option 3:From custom provider that is implementation of IAdsPushConfigurationProvider interface.<br>    services.AddAdsPush&lt;MyProvider&gt;();<br>    <br>}   </pre><p>And put the following section in your in your appsettings.[ENV].json</p><pre>{<br>  &quot;Logging&quot;: {<br>  ...<br>  },<br>  &quot;AdsPush&quot;: {<br>    &quot;MyApp&quot;: { <br>      &quot;TargetMappings&quot;: {<br>        &quot;Ios&quot;: &quot;Apns&quot;,<br>        &quot;Android&quot;: &quot;FirebaseCloudMessaging&quot;<br>      },<br>      &quot;Apns&quot;: {<br>        &quot;P8PrivateKey&quot;: &quot;&lt;p8 certificate string without any space and start and end tags&gt;&quot;,<br>        &quot;P8PrivateKeyId&quot;: &quot;&lt;10 digit p8 certificate id. Usually a part of a downloadable certificate filename&gt;&quot;,<br>        &quot;TeamId&quot;: &quot;&lt;Apple 10 digit team id shown in Apple Developer Membership Page&gt;&quot;,<br>        &quot;AppBundleIdentifier&quot;: &quot;&lt;App slug / bundle name&gt;&quot;,<br>        &quot;EnvironmentType&quot;: &quot;&lt;Apns Env one of Development or Production&gt;&quot;<br>      },<br>      &quot;FirebaseCloudMessaging&quot;: {<br>        &quot;Type&quot;:&quot;&lt;type filed in service_account.json&gt;&quot;,<br>        &quot;ProjectId&quot;:&quot;&lt;project_id filed in service_account.json&gt;&quot;,<br>        &quot;PrivateKey&quot;: &quot;&lt;private_key filed in service_account.json&gt;&quot;,<br>        &quot;PrivateKeyId&quot;: &quot;&lt;private_key_id filed in service_account.json&gt;&quot;,<br>        &quot;ClientId&quot;: &quot;&lt;client_id filed in service_account.json&gt;&quot;,<br>        &quot;ClientEmail&quot;: &quot;&lt;client_email filed in service_account.json&gt;&quot;,<br>        &quot;AuthUri&quot;: &quot;&lt;auth_uri filed in service_account.json&gt;&quot;,<br>        &quot;AuthProviderX509CertUrl&quot;: &quot;&lt;auth_provider_x509_cert_url filed in service_account.json&gt;&quot;,<br>        &quot;TokenUri&quot;: &quot;&lt;client_x509_cert_url filed in service_account.json&gt;&quot;,<br>        &quot;ClientX509CertUrl&quot;: &quot;&lt;token_uri filed in service_account.json&gt;&quot;<br>      }<br>    }<br>  }<br> ...<br>}</pre><p>If you wish to use host/pod environment or any secret provider you can set the following environment variables.</p><pre>AdsPush__MyApp__Apns__AppBundleIdentifier=&lt;App slug / bundle name&gt;<br>AdsPush__MyApp__Apns__EnvironmentType=&lt;Apns Env one of Development or Production&gt;<br>AdsPush__MyApp__Apns__P8PrivateKey=&lt;p8 certificate string without any space and start and end tags&gt;<br>AdsPush__MyApp__Apns__P8PrivateKeyId=&lt;10 digit p8 certificate id. Usually a part of a downloadable certificate filename&gt;<br>AdsPush__MyApp__Apns__TeamId=&lt;Apple 10 digit team id shown in Apple Developer Membership Page&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__AuthProviderX509CertUrl=&lt;auth_provider_x509_cert_url filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__AuthUri=&lt;auth_uri filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__ClientEmail=&lt;client_email filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__ClientId=&lt;client_id filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__ClientX509CertUrl=&lt;token_uri filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__PrivateKey=&lt;private_key filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__PrivateKeyId=&lt;private_key_id filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__ProjectId=&lt;project_id filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__TokenUri=&lt;client_x509_cert_url filed in service_account.json&gt;<br>AdsPush__MyApp__FirebaseCloudMessaging__Type=&lt;type filed in service_account.json&gt;<br>AdsPush__MyApp__TargetMappings__Android=FirebaseCloudMessaging<br>AdsPush__MyApp__TargetMappings__Ios=Apns</pre><p>Now, you can easily use wia DI as the. following.</p><pre>private readonly IAdsPushSender _pushSender;<br>public MyService(<br>    IAdsPushSenderFactory adsPushSenderFactory)<br>{<br>    this._pushSender = adsPushSenderFactory.GetSender(&quot;MyApp&quot;);<br>}</pre><p><strong>2. Using direct sender instance</strong></p><p>The following lines of codes can be used without any DI configuration.</p><pre><br>using AdsPush;<br>using AdsPush.Abstraction;<br>using AdsPush.Abstraction.Settings;<br><br>var builder = new AdsPushSenderBuilder();<br>var apnsSettings = new AdsPushAPNSSettings()<br>{<br>    //put your configurations hare.<br>};<br><br>var firebaseSettings = new AdsPushFirebaseSettings()<br>{<br>    //put your configurations hare.<br>};<br><br>var sender = builder<br>    .ConfigureApns(apnsSettings, null)<br>    .ConfigureFirebase(firebaseSettings, AdsPushTarget.Android)<br>    .BuildSender();</pre><h3>Sending notifications</h3><p>When you obtain an IAdsPushSender instance by using one of the methods shown above, you’re ready to send a notification. The following sample code can be used to trigger a basic notification request.</p><pre><br>await sender.BasicSendAsync(<br>    AdsPushTarget.Ios,<br>    &quot;79eb1b9e623bbca0d2b218f44a18d7b8ef59dac4da5baa9949c3e99a48eb259a&quot;,<br>    new ()<br>    {<br>        Title = AdsPushText.CreateUsingString(&quot;test&quot;),<br>        Detail = AdsPushText.CreateUsingString(&quot;detail&quot;),<br>        Badge = 52,<br>        Sound = &quot;default&quot;,<br>        Parameters = new Dictionary&lt;string, object&gt;()<br>        {<br>            {&quot;pushParam1&quot;,&quot;value1&quot;},<br>            {&quot;pushParam2&quot;,&quot;value2&quot;},<br>        }<br>    });</pre><p>If you wish to access all the parameters supported by the related platform, the following methods can be helpful:</p><pre><br><br>//sample for Apns<br>var apnsResult = await sender<br>    .GetApnsSender()<br>    .SendAsync(<br>        new APNSRequest()<br>        {<br>            ApnsPayload = new()<br>            {<br>                Badge = 52,<br>                Sound = &quot;&quot;,<br>                MutableContent = true,<br>                FilterCriteria = &quot;&quot;,<br>                ThreadId = &quot;&quot;,<br>                TargetContentId = &quot;&quot;,<br>                Alert = new APNSAlert()<br>                {<br>                    Title = &quot;&quot;,<br>                    Body = &quot;&quot;,<br>                    Subtitle = &quot;&quot;<br>                }<br>                //more...<br>            },<br>            AdditionalParameters = new Dictionary&lt;string, object&gt;()<br>            {<br>                {&quot;pushParam1&quot;, &quot;value1&quot; },<br>                {&quot;pushParam2&quot;, &quot;value2&quot;},<br>                {&quot;pushParam3&quot;, 52},<br>            }<br>        },<br>        &quot;79eb1b9e623bbca0d2b218f44a18d7b8ef59dac4da5baa9949c3e99a48eb259a&quot;,<br>        Guid.NewGuid());<br><br>//sample for FCM<br>var firebaseResult = await sender<br>    .GetFirebaseSender()<br>    .SendToSingleAsync(new Message()<br>    {<br>        Token = &quot;&quot;,<br>        Android = new AndroidConfig()<br>        {<br>            Priority = Priority.High,<br>        },<br>        Notification = new()<br>        {<br>            Title = &quot;&quot;,<br>            Body = &quot;&quot;,<br>            ImageUrl = &quot;&quot;<br>        }<br>    });</pre><h3><strong>Conclusion: Elevating Engagement with AdsPush</strong></h3><p>In conclusion, AdsPush offers more than just push notifications; it offers a path to meaningful connections with your app’s users. Seamlessly integrating with APNS and FCM, AdsPush lets you communicate effortlessly across iOS and Android platforms. This open-source gem invites you to contribute on GitHub, collectively shaping the future of engagement.</p><p>As developers, we’re not just building apps; we’re crafting experiences. By embracing AdsPush’s power, we amplify communication, create resonance, and strengthen bonds. Let’s embark on this journey together, reshaping how our apps connect and inspire in the digital landscape. Cheers to building apps that resonate and connect in the most elegant way possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92a7392d1a53" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adessoturkey/adspush-sending-server-side-push-notifications-using-net-92a7392d1a53">AdsPush: Sending Server-Side Push Notifications Using .NET</a> was originally published in <a href="https://medium.com/adessoturkey">adessoTurkey</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>