<?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 Jatin Dave on Medium]]></title>
        <description><![CDATA[Stories by Jatin Dave on Medium]]></description>
        <link>https://medium.com/@techbrainhub?source=rss-b5d49f012c2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xvOUhW3TOUSBAw5-</url>
            <title>Stories by Jatin Dave on Medium</title>
            <link>https://medium.com/@techbrainhub?source=rss-b5d49f012c2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 08:25:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@techbrainhub/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[Announcing SQLDBEntityNotifier: Effortless Real-Time SQL Server Change Tracking for .NET]]></title>
            <link>https://medium.com/@techbrainhub/announcing-sqldbentitynotifier-effortless-real-time-sql-server-change-tracking-for-net-404a4e027eeb?source=rss-b5d49f012c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/404a4e027eeb</guid>
            <category><![CDATA[nuget]]></category>
            <category><![CDATA[change-tracking]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Jatin Dave]]></dc:creator>
            <pubDate>Sat, 02 Aug 2025 20:27:30 GMT</pubDate>
            <atom:updated>2025-08-18T13:55:22.239Z</atom:updated>
            <content:encoded><![CDATA[<h3>Announcing SQLDBEntityNotifier: Effortless Real-Time SQL Server Change Tracking for .NET</h3><p>I’m excited to announce the release of <a href="https://www.nuget.org/packages/SQLDBEntityNotifier">SQLDBEntityNotifier</a>, a lightweight, event-driven .NET library for SQL Server change tracking notifications. Built for Entity Framework Core, it enables developers to easily react to database changes—insert, update, delete, and errors—in real time, with just a few lines of code.</p><p><strong>Key Features:</strong></p><ul><li>Works with .NET 6+ and EF Core 6+</li><li>Simple DI registration and usage</li><li>Supports both in-memory and real SQL Server databases</li><li>Comprehensive unit tests and MIT license</li><li>Open source: <a href="https://github.com/jatinrdave/SQLEFTableNotification">GitHub</a></li><li>Nuget package: <a href="https://www.nuget.org/packages/SQLDBEntityNotifier">https://www.nuget.org/packages/SQLDBEntityNotifier</a></li></ul><p><strong>Getting Started:</strong></p><pre>services.AddSQLDBNotifier();<br><br>var changeService = new ChangeTableService&lt;User&gt;(dbContext);<br>var notificationService = new SqlDBNotificationService&lt;User&gt;(<br>    changeService,<br>    &quot;Users&quot;,<br>    connectionString,<br>    -1L,<br>    null,<br>    ver =&gt; $&quot;SELECT * FROM Users&quot;<br>);<br><br>notificationService.OnChanged += (sender, args) =&gt;<br>{<br>    foreach (var user in args.Entities ?? Enumerable.Empty&lt;User&gt;())<br>        Console.WriteLine($&quot;User changed: {user.Name}&quot;);<br>};<br><br>notificationService.OnError += (sender, args) =&gt;<br>    Console.WriteLine($&quot;Error: {args.Message}&quot;);<br><br>await notificationService.PollForChangesAsync();</pre><p><strong>Why Use SQLDBEntityNotifier?</strong></p><ul><li>No more polling or manual change detection</li><li>Clean, event-driven API</li><li>Easily extensible for any table or entity</li><li>Perfect for building real-time dashboards, audit logs, or notification systems</li></ul><p>Read the full story and technical deep dive in my Medium article:<br><a href="https://medium.com/@techbrainhub/building-a-real-time-database-notification-service-with-change-tracking-in-c-9512a2d14641">Building a Real-Time Database Notification Service with Change Tracking in C#</a></p><p>Try it out, contribute, and let me know your feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=404a4e027eeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Asynchronous Callbacks in .NET With Real-World Example]]></title>
            <link>https://medium.com/@techbrainhub/mastering-asynchronous-callbacks-in-net-with-real-world-example-e8cef2f50f7f?source=rss-b5d49f012c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8cef2f50f7f</guid>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[callback]]></category>
            <category><![CDATA[async]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Jatin Dave]]></dc:creator>
            <pubDate>Thu, 20 Feb 2025 13:05:10 GMT</pubDate>
            <atom:updated>2025-02-20T15:18:22.517Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Asynchronous Callbacks in .NET With Real-World Example</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*YnGs0_Ju_gIGfZhfOQKsRg.png" /></figure><h3>Introduction</h3><p>Modern software development relies heavily on asynchronous programming, which allows applications to remain dynamic while still handling repetitive tasks such as network connections and file transfers. Asynchronous programming relies heavily on the asynchronous callback, which facilitates function execution after an upcoming operation is completed. This technique takes advantage of this fact. What are asynchronous callbacks, where can we use them, and how do we implement it with an example file upload on FTP using .NET?</p><h4>What Are Asynchronous Callbacks?</h4><p>A function that is passed to an asynchronous method is called an argument in the corresponding function. When this asynchronous task ends, the callback is called, and the result of the operation is returned.</p><p>This is particularly useful when performing long-running tasks like:</p><p>✅ <strong>Network communication</strong> (e.g., API calls, FTP transfers)<br>✅ <strong>File operations</strong> (e.g., reading/writing large files)<br>✅ <strong>Database queries</strong> (e.g., executing SQL queries asynchronously)<br>✅ <strong>UI interactions</strong> (e.g., keeping UI responsive in desktop apps)</p><h4>Why Use Asynchronous Callbacks?</h4><p>Imagine you’re building an application that uploads large files to an <strong>FTP server</strong>. If the application waits synchronously for the upload to complete, it will freeze the UI or block other operations.</p><p>By using asynchronous callbacks, we can:</p><p>🔹 <strong>Avoid blocking the main thread</strong>, ensuring the app remains responsive.<br>🔹 <strong>Receive real-time updates</strong> about upload progress.<br>🔹 <strong>Trigger actions</strong> when the upload completes, such as logging results or updating the UI.</p><h4>Real-World Example: Asynchronous FTP Upload with Callbacks in .NET</h4><p>Let’s implement an <strong>FTP file upload</strong> using the <a href="https://github.com/robinrodricks/FluentFTP">FluentFTP</a> library and demonstrate how to use <strong>asynchronous callbacks</strong> to handle the upload result.</p><h4><strong>Step 1: Install FluentFTP</strong></h4><p>First, install the <strong>FluentFTP</strong> package via NuGet:</p><pre>dotnet add package FluentFTP</pre><h4>Step 2: Implement the Callback Function</h4><p>We define a callback function that will be <strong>triggered when the FTP upload completes</strong>. It will display a success or failure message.</p><pre>public static void UploadCompletedCallback(bool success)<br>{<br>    Console.WriteLine(success ? &quot;✅ Upload successful!&quot; : &quot;❌ Upload failed.&quot;);<br>}</pre><h4>Step 3: Perform Asynchronous FTP Upload with a Callback</h4><p>Now, we implement an <strong>async method</strong> to upload a file to an FTP server. This method takes a <strong>callback function</strong> as a parameter and invokes it once the upload is complete.</p><pre>using FluentFTP;<br>using System;<br>using System.Threading.Tasks;<br><br>class Program<br>{<br>    static async Task Main()<br>    {<br>        var client = new AsyncFtpClient(&quot;ftp.example.com&quot;, &quot;username&quot;, &quot;password&quot;);<br>        await client.Connect(); // Connect asynchronously<br><br>        // Call the upload method and pass the callback<br>        await UploadFileAsync(client, @&quot;C:\path\to\file.txt&quot;, &quot;/remote/path/file.txt&quot;, UploadCompletedCallback);<br><br>        await client.Disconnect();<br>    }<br><br>    // FTP upload method with a callback<br>    public static async Task UploadFileAsync(AsyncFtpClient client, string localPath, string remotePath, Action&lt;bool&gt; callback)<br>    {<br>        try<br>        {<br>            bool success = await client.UploadFile(localPath, remotePath);<br>            callback?.Invoke(success); // Invoke the callback after upload completion<br>        }<br>        catch<br>        {<br>            callback?.Invoke(false);<br>        }<br>    }<br>}</pre><h4>How It Works?</h4><ol><li>The UploadFileAsync method performs the <strong>FTP upload asynchronously</strong>.</li><li>Once the upload completes, it <strong>triggers the callback</strong> (UploadCompletedCallback) with the upload status.</li><li>This prevents blocking the <strong>main thread</strong>, ensuring a smooth user experience.</li></ol><h4>Enhancing the Callback with Upload Progress</h4><p>We can improve our callback by tracking <strong>upload progress</strong>. FluentFTP provides an UploadProgress event, which we can use to update the user in real time.</p><pre>client.UploadProgress += (progress) =&gt;<br>{<br>    Console.WriteLine($&quot;Uploading... {progress.Progress}% completed&quot;);<br>};</pre><h3>Conclusion</h3><p>Asynchronous callbacks are a powerful tool in .NET for handling time-consuming operations <strong>without blocking the main thread</strong>. In this article, we demonstrated how to use callbacks with <strong>real-world FTP file uploads</strong> using the FluentFTP library.</p><p>By using this approach, you can:<br>✅ Keep applications responsive<br>✅ Handle large file transfers efficiently<br>✅ Provide real-time progress updates</p><p>For more details on <strong>asynchronous callbacks</strong>, check out Microsoft’s official documentation:<br>🔗 <a href="https://learn.microsoft.com/en-us/dotnet/standard/asynchronous-programming-patterns/using-an-asynccallback-delegate-and-state-object">Asynchronous Callbacks in .NET</a></p><p>🚀 <strong>Did you find this useful? Let me know in the comments!</strong></p><p>#dotnet #async #callbacks #FTP #csharp #developers #medium</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8cef2f50f7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transform Your Angular App into a Cross-Platform PWA: A Developer’s Guide]]></title>
            <link>https://medium.com/@techbrainhub/transform-your-angular-app-into-a-cross-platform-pwa-a-developers-guide-2d7cef17fabe?source=rss-b5d49f012c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d7cef17fabe</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[web-app-development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Jatin Dave]]></dc:creator>
            <pubDate>Sun, 09 Feb 2025 14:01:33 GMT</pubDate>
            <atom:updated>2026-10-07T12:22:25.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*9StgOsrb0d9MczyjfJNoKA.png" /></figure><p>In today’s mobile-first environment, Progressive Web Apps (PWAs) are becoming more crucial. As a developer who has assisted numerous teams in transitioning their Angular applications to PWAs, I’d want to give a practical guide to help you successfully navigate this road.</p><p><strong>Why PWA? The Real-World Benefits</strong></p><p>Imagine you’re developing a task management software. As a standard online app, it would need constant internet connectivity and would not seem natural on mobile devices. Converting it to a PWA allows your users to:</p><ul><li>Continue to manage work even when offline during their early commute.</li><li>Install it immediately to their home screen, like a native app.</li><li>Receive push alerts for task updates.</li><li>Experience faster loading times thanks to caching.</li></ul><p><strong>The Transition Process: Truly Easy</strong></p><p><strong>Step 1: Adding PWA Support</strong></p><pre>ng add @angular/pwa</pre><p>This command will:</p><ul><li>Install the required dependencies.</li><li>Configure your app with a service worker.</li><li>Generate a <em>manifest.webmanifest</em> file.</li><li>Update the <em>angular.json</em> file to include service worker settings.</li></ul><p><strong>Step 2: Update <em>manifest.webmanifest </em>file</strong></p><p>Customise the src/manifest.webmanifest file to include:</p><ul><li>Application name, short name, and description.</li><li>Icons for different screen sizes.</li><li>Display mode (standalone, fullscreen, etc.).</li><li>Background color and theme color.</li></ul><p>Add app icons to the src/assets/icons/ directory, ensuring they meet the required resolutions.</p><pre>{<br>  &quot;name&quot;: &quot;My Angular PWA&quot;,<br>  &quot;short_name&quot;: &quot;AngularPWA&quot;,<br>  &quot;theme_color&quot;: &quot;#1976d2&quot;,<br>  &quot;background_color&quot;: &quot;#ffffff&quot;,<br>  &quot;display&quot;: &quot;standalone&quot;,<br>  &quot;start_url&quot;: &quot;/&quot;,<br>  &quot;icons&quot;: [<br>    {<br>      &quot;src&quot;: &quot;assets/icons/icon-192x192.png&quot;,<br>      &quot;sizes&quot;: &quot;192x192&quot;,<br>      &quot;type&quot;: &quot;image/png&quot;<br>    },<br>    {<br>      &quot;src&quot;: &quot;assets/icons/icon-512x512.png&quot;,<br>      &quot;sizes&quot;: &quot;512x512&quot;,<br>      &quot;type&quot;: &quot;image/png&quot;<br>    }<br>  ]<br>}</pre><p><strong>Step 3: Enable Service Worker</strong>: Angular’s PWA support includes a service worker for offline capabilities. Verify that the service worker is enabled in your <em>angular.json</em> file:</p><pre>&quot;projects&quot;: {<br>  &quot;your-app-name&quot;: {<br>    &quot;architect&quot;: {<br>      &quot;build&quot;: {<br>        &quot;options&quot;: {<br>          &quot;serviceWorker&quot;: true,<br>          &quot;ngswConfigPath&quot;: &quot;ngsw-config.json&quot;<br>        }<br>      }<br>    }<br>  }<br>}</pre><p><strong>Configure the ngsw-config.json File</strong>: The service worker configuration file ngsw-config.json can be customised to control caching strategies, asset groups, and data groups.</p><pre>{<br>  &quot;index&quot;: &quot;/index.html&quot;,<br>  &quot;assetGroups&quot;: [<br>    {<br>      &quot;name&quot;: &quot;app&quot;,<br>      &quot;installMode&quot;: &quot;prefetch&quot;,<br>      &quot;resources&quot;: {<br>        &quot;files&quot;: [<br>          &quot;/favicon.ico&quot;,<br>          &quot;/index.html&quot;,<br>          &quot;/*.css&quot;,<br>          &quot;/*.js&quot;<br>        ]<br>      }<br>    },<br>    {<br>      &quot;name&quot;: &quot;assets&quot;,<br>      &quot;installMode&quot;: &quot;lazy&quot;,<br>      &quot;updateMode&quot;: &quot;prefetch&quot;,<br>      &quot;resources&quot;: {<br>        &quot;files&quot;: [<br>          &quot;/assets/**&quot;,<br>          &quot;/*.png&quot;<br>        ]<br>      }<br>    }<br>  ]<br>}</pre><p><strong>Step 4: Building in Offline Resilience</strong></p><p>The true power of PWAs lies in their offline capabilities. Here’s how we handle offline task creation in our example:</p><ol><li>User creates a task while offline</li><li>Task is stored in IndexedDB</li><li>Once online (or the next time the app opens), our sync routine kicks in:</li></ol><pre>async function syncOfflineActions() {<br>  const db = await openDB(&#39;TaskMasterDB&#39;, 1);<br>  const tasks = await db.getAll(&#39;pendingTasks&#39;);<br>  <br>  for (const task of tasks) {<br>    try {<br>      await fetch(&#39;/api/tasks&#39;, {<br>        method: &#39;POST&#39;,<br>        body: JSON.stringify(task)<br>      });<br>      await db.delete(&#39;pendingTasks&#39;, task.id);<br>    } catch (err) {<br>      // Will retry automatically<br>    }<br>  }<br>}</pre><p><strong>Step 5: Build your application</strong></p><p>Build with the production flag to enable service workers:</p><pre>ng build</pre><p><strong>Step 6: Test the PWA</strong></p><ul><li>Use Chrome DevTools to audit the PWA using the <strong>Lighthouse</strong> tool.</li><li>Verify offline functionality, the manifest file, and app installation prompts.</li></ul><p><strong>Offline Capabilities: How Far Can a PWA Go?</strong></p><p>In Step 4, our task manager saved tasks to IndexedDB and synced them once the user was back online. For many apps, that’s all the offline support you need. But “works offline” can mean very different things. Opening a cached list of tasks on the train is one level. A field engineer creating dozens of tasks, attaching photos, and working without signal for two days is a completely different one.</p><p>Before you decide how to ship your app, ask one question: <strong>how long, and how much, do your users need to work without a connection?</strong> The answer tells you whether a pure PWA is enough or whether you should wrap the same Angular code in a native shell with Capacitor.</p><p>A PWA handles short offline gaps very well: the service worker caches the app shell, IndexedDB stores pending changes, and everything syncs when the app reopens. The limits show up on iOS in particular. Safari doesn’t support the Background Sync API, so syncing only happens while the app is open. The browser can also clear stored data for sites that haven’t been added to the home screen and haven’t been used for a while. Capacitor removes most of these limits. It gives you SQLite storage the OS won’t clear, secure token storage in the Keychain or Keystore, native camera access, and full push notifications. The cost is app-store releases and some platform-specific setup.</p><p>Here’s how the two compare for offline work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Z4O8sQkXmcMVggikAZjKiA.png" /><figcaption>PWA vs Capacitor for offline</figcaption></figure><p><strong>A practical rule of thumb:</strong> if users only need to read cached data and recover from short connection drops, a PWA is the simplest and fastest route. If they create important data offline for hours or days, or need reliable storage, native device features, or secure credentials, use Capacitor.</p><p>The good news is that you don’t have to choose up front. Keep your storage and sync logic behind an Angular service, for example a StorageService with an IndexedDB implementation for the web and a SQLite implementation for native. Then the same codebase can ship as a PWA today and as a Capacitor app later, without rewriting your features.</p><p><strong>Putting It Into Practice: One Storage Service, Two Platforms</strong></p><p>The trick to supporting both a PWA and a Capacitor app is to keep your components unaware of <em>where</em> data is stored. We define a small abstract class, add one implementation for the browser (IndexedDB) and one for native (SQLite), and let Angular’s dependency injection pick the right one at startup.</p><p>First, install the packages:</p><pre>npm install idb<br>npm install @capacitor/core @capacitor-community/sqlite<br>npx cap sync</pre><ol><li><strong>Define the contract</strong></li></ol><pre>// task-storage.ts<br>export interface PendingTask {<br>  id: string;<br>  title: string;<br>  createdAt: string;<br>}<br><br>export abstract class TaskStorage {<br>  abstract addPending(task: PendingTask): Promise&lt;void&gt;;<br>  abstract getPending(): Promise&lt;PendingTask[]&gt;;<br>  abstract removePending(id: string): Promise&lt;void&gt;;<br>}</pre><p>2. Browser implementation (IndexedDB)</p><pre>// indexeddb-task-storage.ts<br>import { Injectable } from &#39;@angular/core&#39;;<br>import { openDB } from &#39;idb&#39;;<br>import { PendingTask, TaskStorage } from &#39;./task-storage&#39;;<br><br>@Injectable()<br>export class IndexedDbTaskStorage extends TaskStorage {<br>  private db = openDB(&#39;TaskMasterDB&#39;, 1, {<br>    upgrade(db) {<br>      db.createObjectStore(&#39;pendingTasks&#39;, { keyPath: &#39;id&#39; });<br>    },<br>  });<br><br>  async addPending(task: PendingTask) {<br>    await (await this.db).put(&#39;pendingTasks&#39;, task);<br>  }<br><br>  async getPending(): Promise&lt;PendingTask[]&gt; {<br>    return (await this.db).getAll(&#39;pendingTasks&#39;);<br>  }<br><br>  async removePending(id: string) {<br>    await (await this.db).delete(&#39;pendingTasks&#39;, id);<br>  }<br>}</pre><p>3. Native implementation (SQLite via Capacitor)</p><pre>// sqlite-task-storage.ts<br>import { Injectable } from &#39;@angular/core&#39;;<br>import { CapacitorSQLite, SQLiteConnection, SQLiteDBConnection } from &#39;@capacitor-community/sqlite&#39;;<br>import { PendingTask, TaskStorage } from &#39;./task-storage&#39;;<br><br>@Injectable()<br>export class SqliteTaskStorage extends TaskStorage {<br>  private sqlite = new SQLiteConnection(CapacitorSQLite);<br>  private db: Promise&lt;SQLiteDBConnection&gt; = this.init();<br><br>  private async init() {<br>    const db = await this.sqlite.createConnection(&#39;taskmaster&#39;, false, &#39;no-encryption&#39;, 1, false);<br>    await db.open();<br>    await db.execute(`CREATE TABLE IF NOT EXISTS pending_tasks (<br>      id TEXT PRIMARY KEY, title TEXT NOT NULL, createdAt TEXT NOT NULL)`);<br>    return db;<br>  }<br><br>  async addPending(t: PendingTask) {<br>    await (await this.db).run(<br>      &#39;INSERT OR REPLACE INTO pending_tasks (id, title, createdAt) VALUES (?, ?, ?)&#39;,<br>      [t.id, t.title, t.createdAt]);<br>  }<br><br>  async getPending(): Promise&lt;PendingTask[]&gt; {<br>    const result = await (await this.db).query(&#39;SELECT * FROM pending_tasks ORDER BY createdAt&#39;);<br>    return (result.values ?? []) as PendingTask[];<br>  }<br><br>  async removePending(id: string) {<br>    await (await this.db).run(&#39;DELETE FROM pending_tasks WHERE id = ?&#39;, [id]);<br>  }<br>}</pre><p>4. Let Angular choose at startup</p><pre>// app.config.ts<br>import { ApplicationConfig, isDevMode } from &#39;@angular/core&#39;;<br>import { provideHttpClient, withFetch } from &#39;@angular/common/http&#39;;<br>import { provideServiceWorker } from &#39;@angular/service-worker&#39;;<br>import { Capacitor } from &#39;@capacitor/core&#39;;<br>import { TaskStorage } from &#39;./task-storage&#39;;<br>import { IndexedDbTaskStorage } from &#39;./indexeddb-task-storage&#39;;<br>import { SqliteTaskStorage } from &#39;./sqlite-task-storage&#39;;<br><br>const isNative = Capacitor.isNativePlatform();<br><br>export const appConfig: ApplicationConfig = {<br>  providers: [<br>    provideHttpClient(withFetch()),<br>    // The service worker is only needed on the web; Capacitor already serves files locally.<br>    provideServiceWorker(&#39;ngsw-worker.js&#39;, {<br>      enabled: !isDevMode() &amp;&amp; !isNative,<br>      registrationStrategy: &#39;registerWhenStable:30000&#39;,<br>    }),<br>    { provide: TaskStorage, useClass: isNative ? SqliteTaskStorage : IndexedDbTaskStorage },<br>  ],<br>};</pre><p><strong>5. A sync service that works everywhere</strong></p><p>Because iOS Safari has no Background Sync, we sync when the device comes back online <em>and</em> whenever the app returns to the foreground. Signals make it easy to show an “offline” badge or a pending-items counter in the UI.</p><pre>// task-sync.service.ts<br>import { Injectable, inject, signal } from &#39;@angular/core&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br>import { firstValueFrom } from &#39;rxjs&#39;;<br>import { TaskStorage } from &#39;./task-storage&#39;;<br><br>@Injectable({ providedIn: &#39;root&#39; })<br>export class TaskSyncService {<br>  private storage = inject(TaskStorage);<br>  private http = inject(HttpClient);<br><br>  readonly online = signal(navigator.onLine);<br>  readonly pendingCount = signal(0);<br>  private syncing = false;<br><br>  constructor() {<br>    window.addEventListener(&#39;online&#39;, () =&gt; { this.online.set(true); this.sync(); });<br>    window.addEventListener(&#39;offline&#39;, () =&gt; this.online.set(false));<br>    document.addEventListener(&#39;visibilitychange&#39;, () =&gt; {<br>      if (document.visibilityState === &#39;visible&#39;) this.sync();<br>    });<br>    this.refreshCount();<br>  }<br><br>  async createTask(title: string) {<br>    const task = { id: crypto.randomUUID(), title, createdAt: new Date().toISOString() };<br>    await this.storage.addPending(task);<br>    await this.refreshCount();<br>    if (this.online()) await this.sync();<br>  }<br><br>  async sync() {<br>    if (this.syncing || !this.online()) return;<br>    this.syncing = true;<br>    try {<br>      for (const task of await this.storage.getPending()) {<br>        // The task id doubles as an idempotency key, so a retried request never creates duplicates.<br>        await firstValueFrom(this.http.post(&#39;/api/tasks&#39;, task, {<br>          headers: { &#39;Idempotency-Key&#39;: task.id },<br>        }));<br>        await this.storage.removePending(task.id);<br>      }<br>    } catch {<br>      // Still offline or server error — remaining tasks stay queued for the next attempt.<br>    } finally {<br>      this.syncing = false;<br>      await this.refreshCount();<br>    }<br>  }<br><br>  private async refreshCount() {<br>    this.pendingCount.set((await this.storage.getPending()).length);<br>  }<br>}</pre><p>Your components only ever call TaskSyncService.createTask(). Whether the task lands in IndexedDB in Chrome or in SQLite on an iPad, the feature code stays exactly the same. That is what lets you start with a PWA and move to Capacitor later without a rewrite.</p><p><strong>Cross-Platform Deployment: One App, Multiple Stores</strong></p><p>Deploying a <strong>Progressive Web App (PWA)</strong> as an app to <strong>Android</strong> and <strong>iOS</strong> devices involves slightly different processes for each platform. Here’s a step-by-step guide for both:</p><p><strong>1. Deploying a PWA on Android</strong></p><p><strong>Steps to Deploy as an App on Android:</strong></p><ol><li><strong>Optimise Your PWA</strong>:</li></ol><ul><li>Ensure the app meets <strong>PWA requirements</strong>:</li><li>Has a valid <em>manifest.json</em> file.</li><li>Serves content over HTTPS.</li><li>Implements a service worker for offline capabilities.</li><li>Example <em>manifest.json</em>:</li></ul><pre>{<br>  &quot;name&quot;: &quot;My PWA&quot;,<br>  &quot;short_name&quot;: &quot;PWA&quot;,<br>  &quot;start_url&quot;: &quot;/index.html&quot;,<br>  &quot;display&quot;: &quot;standalone&quot;,<br>  &quot;background_color&quot;: &quot;#ffffff&quot;,<br>  &quot;theme_color&quot;: &quot;#000000&quot;,<br>  &quot;icons&quot;: [<br>    {<br>      &quot;src&quot;: &quot;icon-192x192.png&quot;,<br>      &quot;sizes&quot;: &quot;192x192&quot;,<br>      &quot;type&quot;: &quot;image/png&quot;<br>    },<br>    {<br>      &quot;src&quot;: &quot;icon-512x512.png&quot;,<br>      &quot;sizes&quot;: &quot;512x512&quot;,<br>      &quot;type&quot;: &quot;image/png&quot;<br>    }<br>  ]<br>}</pre><p><strong>3. Install Directly via Chrome</strong>:</p><ul><li>Open the PWA in Chrome on Android.</li><li>Tap the menu (three dots) and select <strong>“Add to Home screen.”</strong>.</li><li>The PWA will install as a standalone app.</li></ul><p><strong>4. Wrap the PWA as an APK</strong>: If you want to publish the PWA on the Google Play Store:</p><ul><li>Use <strong>Trusted Web Activity (TWA)</strong>:</li><li>TWA allows you to package the PWA into an APK for distribution.</li><li>Use tools like <strong>Bubblewrap</strong>:</li></ul><pre>npm install -g @bubblewrap/cli<br>bubblewrap init<br>bubblewrap build</pre><ul><li>This generates a signed APK ready for the Play Store.</li></ul><p><strong>5. Publish to Google Play Store</strong>:</p><ul><li>Create a Google Play Developer account.</li><li>Upload the APK through the Google Play Console.</li><li>Provide app details, including icons, screenshots, and descriptions.</li><li>Submit for review.</li></ul><p><strong>2. Deploying a PWA on iOS</strong></p><p><strong>Steps to Deploy as an App on iOS:</strong></p><ol><li><strong>Optimise Your PWA</strong>:</li></ol><ul><li>Ensure the app meets Apple’s PWA requirements:</li><li>A valid manifest.json file.</li><li><strong>Apple-specific meta tags</strong> in your HTML:</li></ul><pre>&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&quot;&gt;<br>&lt;link rel=&quot;apple-touch-icon&quot; href=&quot;icon-192x192.png&quot;&gt;</pre><ul><li>Serve content over HTTPS.</li></ul><p><strong>2. Test the PWA</strong>:</p><ul><li>Open the PWA in <strong>Safari</strong> on an iOS device.</li><li>Verify its functionality and offline capabilities.</li></ul><p><strong>3. Install as a Web App via Safari</strong>:</p><ul><li>Open the PWA in Safari on an iPhone or iPad.</li><li>Tap the <strong>“Share”</strong> button, then select <strong>“Add to Home Screen.”</strong>.</li><li>The PWA will install and behave like a standalone app.</li></ul><p><strong>4. Wrap the PWA as a Native App</strong>: If you want to publish the PWA on the App Store:</p><ul><li>Use tools like <strong>Capacitor.js</strong> or <strong>PWABuilder</strong>:</li><li>Wrap your PWA into a native iOS app.</li><li>Generate an <strong>Xcode project</strong> for further customisation.</li><li>Example with Capacitor:</li></ul><pre>npm install @capacitor/cli @capacitor/core<br>npx cap init<br>npx cap add ios<br>npx cap open ios</pre><ul><li>Open the project in <strong>Xcode</strong> and configure it:</li><li>Set the <strong>bundle identifier</strong> and <strong>App Store settings</strong>.</li><li>Add necessary permissions and capabilities.</li></ul><p><strong>5. Publish to the App Store</strong>:</p><ul><li>Create an Apple Developer account.</li><li>Use Xcode to archive and upload the app to App Store Connect.</li><li>Provide app metadata, screenshots, and descriptions.</li></ul><p>Submit the app for review and release.</p><p><strong>Conclusion</strong></p><p>Turning your Angular app into a PWA creates new chances to get users involved and make your app work offline. You’ll need to plan it out, but it’s worth the work you put in. Begin with small steps, make things better bit by bit, and always think about what your users need. Keep this in mind: a great PWA doesn’t just work when there’s no internet—it runs so smoothly that people forget they’re using a web app at all.</p><p><em>What has been your experience with PWAs? I’d love to hear about your journey and challenges in the comments below.</em></p><p>Will end up here. In the next article, I will talk about more PWA. See you soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d7cef17fabe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure Communication Services Email — A Symphony of Simplicity and Power for .NET Apps]]></title>
            <link>https://medium.com/@techbrainhub/azure-communication-services-email-a-symphony-of-simplicity-and-power-for-net-apps-3e3f28db2cfc?source=rss-b5d49f012c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e3f28db2cfc</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[sendgrid]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[azure-communication]]></category>
            <dc:creator><![CDATA[Jatin Dave]]></dc:creator>
            <pubDate>Tue, 23 Jan 2024 12:29:52 GMT</pubDate>
            <atom:updated>2024-01-23T12:29:52.403Z</atom:updated>
            <content:encoded><![CDATA[<h3>Azure Communication Services Email — A Symphony of Simplicity and Power for .NET Apps</h3><p>Email remains a crucial communication channel for businesses globally. Integrating email capabilities into your .NET applications can be challenging, requiring managing SMTP servers, ensuring deliverability, and handling spam.</p><p>Cloud-based email services have revolutionized the way we send and receive messages, offering flexibility, scalability, and enhanced security.</p><p>Let’s explore some popular cloud-based email service providers for .NET applications and their key offerings:</p><p>1. <strong>Azure Communication Services:</strong></p><ul><li>Microsoft’s cloud-based platform, offering email as part of a comprehensive communication suite (voice, video, chat, SMS).</li><li>Pre-built .NET libraries and familiar SMTP commands simplify integration.</li><li>Global infrastructure guarantees scalability and reliability.</li><li>High inbox placement rates and advanced spam filtering ensure deliverability.</li><li>Pay-per-use pricing makes it cost-effective for diverse use cases.</li><li>Additional features: email tracking, bulk sending, template management, custom domains.</li></ul><p>2. <strong>SendGrid:</strong></p><ul><li>API-driven email delivery platform renowned for its scalability and high deliverability rates.</li><li>Extensive documentation and SDKs for all major programming languages, including .NET.</li><li>Robust analytics and reporting provide insights into email performance.</li><li>Advanced features: email scheduling, personalization, A/B testing, email API triggers.</li><li>Freemium plan available for low-volume sending.</li></ul><p>3. <strong>Amazon Simple Email Service (SES):</strong></p><ul><li>Cost-effective email service from Amazon Web Services, ideal for high-volume transactional emails.</li><li>Simple integration with AWS infrastructure and other AWS services.</li><li>Pay-as-you-go pricing based on the number of emails sent.</li><li>Basic analytics and reporting for monitoring email delivery.</li><li>Integration with Amazon SNS for sending push notifications.</li></ul><p>4. <strong>Mailgun:</strong></p><ul><li>Developer-friendly API with comprehensive documentation and SDKs for various languages, including .NET.</li><li>Powerful email automation features for personalized campaigns and triggered emails.</li><li>Robust spam filtering and email validation ensure high deliverability and engagement.</li><li>Real-time email tracking and analytics provide detailed insights into campaign performance.</li><li>Freemium plan available for limited usage.</li></ul><p><strong>Choosing the Right Cloud-Based Email Service:</strong></p><p>The best cloud-based email service for your .NET application depends on your specific needs and priorities. The comparison below will give you a brief idea based on requirements.</p><figure><img alt="Comparison Chart" src="https://cdn-images-1.medium.com/max/1024/1*eW9OCEb1FjPN9Z3QtRaQEQ.png" /><figcaption>Different email provider and their feature comparison.</figcaption></figure><p>Also, consider factors like:</p><ul><li>Email volume and frequency: Choose a service that scales with your needs.</li><li>Required features: Prioritize features like deliverability, analytics, automation, and integrations.</li><li>Budget: Compare pricing models and choose a service that fits your budget.</li><li>Ease of integration: Assess the availability of .NET libraries and documentation.</li><li>Security and compliance: Ensure the service meets your data security and privacy requirements.</li></ul><p>With these considerations in mind, explore the vast landscape of cloud-based email services and discover the perfect solution to liberate your .NET applications from the constraints of on-premises servers. Azure Communication Services fits my requirements based on Azure-specific infrastructure apps.</p><p>Benefits of using ACS Email for .NET Apps:</p><ul><li>Simplified Integration: Leverage pre-built .NET libraries and familiar SMTP commands to quickly add email capabilities to your applications.</li><li>Scalability and Reliability: Benefit from Azure’s global infrastructure to handle high-volume email sending without managing your own servers.</li><li>Enhanced Deliverability: Ensure emails reach intended recipients with high inbox placement rates and advanced spam filtering.</li><li>Pay-per-use Pricing: Only pay for the emails you send, making ACS cost-effective for both low and high-volume use cases.</li><li>Multi-channel Communication: Combine email with other ACS communication channels like SMS and chat to create engaging user experiences.</li></ul><p>General or relevant requirements that offer (B2C):</p><ul><li>Omnichannel support: Offer various communication channels like chat, voice calls, and video calls for customer inquiries.</li><li>Remote Services Support: Provide instant support to customers through live chat or video consultations for remote attendant services at Point of Sale.</li><li>Automated notifications: Send personalized updates on order status, delivery alerts, or appointment reminders.</li><li>Product demonstrations: Showcase products or services through live video calls with potential customers.</li><li>Personalized shopping experiences: Offer virtual consultations and recommendations through chat or video.</li><li>Post-purchase: Send order confirmations, shipping updates, and loyalty program information via email and SMS.</li><li>Account updates and alerts: Send notifications about account activity, transactions, and important updates via email and SMS.</li><li>Real-time shipment tracking: Update customers on delivery ETA and location changes through SMS notifications.</li><li>Logistic communication: Communicate instructions and updates to the shipment provider in real time using voice calls and text messages.</li><li>Automated delivery notifications: Send SMS alerts when a package arrives or requires an authentication/signature upon delivery.</li><li>Remote installation guidance: Provide video tutorials or live video calls with technicians to guide customers through the installation process, reducing potential errors and improving DIY adoption</li></ul><p>Demo Project <a href="https://github.com/jatinrdave/AzureEmailService">Link</a></p><h3>Conclusion:</h3><p>In the ever-evolving world of .NET development, Azure Communication Services Email emerges as a harmonious blend of simplicity and power. Its intuitive integration, robust infrastructure, and advanced features empower developers to effortlessly add email capabilities to their applications, focusing on innovation rather than infrastructure management. Whether you prioritize scalability, deliverability, cost-effectiveness, or a comprehensive communication suite, ACS Email strikes the perfect chord. So, unplug from the constraints of on-premises servers, embrace the freedom of the cloud, and let ACS Email orchestrate your .NET application’s communication symphony.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e3f28db2cfc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Real-Time Database Notification Service with Change Tracking in C#]]></title>
            <link>https://medium.com/@techbrainhub/building-a-real-time-database-notification-service-with-change-tracking-in-c-9512a2d14641?source=rss-b5d49f012c2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9512a2d14641</guid>
            <category><![CDATA[database-notification]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[change-tracking]]></category>
            <category><![CDATA[tracking]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Jatin Dave]]></dc:creator>
            <pubDate>Thu, 27 Jul 2023 20:15:18 GMT</pubDate>
            <atom:updated>2025-08-02T20:30:54.799Z</atom:updated>
            <content:encoded><![CDATA[<p>Announcement: <a href="https://www.nuget.org/packages/SQLDBEntityNotifier">SQLDBEntityNotifier</a>. Read the full story <a href="https://medium.com/@techbrainhub/announcing-sqldbentitynotifier-effortless-real-time-sql-server-change-tracking-for-net-404a4e027eeb">here</a>.</p><p>We will explore the implementation of a powerful database notification service in C#, capable of providing real-time updates on data changes in a SQL Server table. By leveraging SQL Server’s Change Tracking feature, we can efficiently monitor and respond to modifications without the need for continuous polling, resulting in a more responsive and resource-efficient application.</p><p>SQL Table Change Notification is required for real-time data synchronization and event-driven applications. It provides a mechanism for applications to be notified when changes occur in a specific SQL database table, allowing them to take appropriate actions based on those changes. There are several reasons why SQL Table Change Notification is essential:</p><p>In distributed systems or scenarios where multiple instances of an application are running,</p><ul><li>Modern applications require real-time data updates to provide timely and accurate information to users.</li><li>Keeping data in sync across all nodes can be challenging.</li><li>Caching is used to improve application performance, but it can lead to stale data if not managed properly.</li><li>Where multiple users can access and modify the same data to resolve conflicts .</li><li>Where applications offer subscription-based services in delivering timely and relevant information to subscribers.</li></ul><p>Overall, SQL Table Change Notification enhances application responsiveness and enables efficient data synchronization, making it a valuable feature for various types of applications that rely on real-time data updates and event-driven behavior.</p><h3>Change Tracking In SQL Server</h3><p>Change Tracking in SQL Server is a lightweight, built-in feature that helps track changes made to user tables in a database. It captures the fact that a row has been inserted, updated, or deleted, without storing the actual data changes. Instead, it records the minimum information needed to identify the modified rows.</p><h3>Enable Change Tracking</h3><p>Enabling Change Tracking in SQL Server involves a straightforward process. Here are the steps to enable Change Tracking for a specific table in a database:</p><pre> --SQL Script for enable change tracking at database level.<br><br>ALTER DATABASE ECommerceDB<br>SET CHANGE_TRACKING = ON<br>(CHANGE_RETENTION = 1 DAYS, AUTO_CLEANUP = ON);<br><br>--SQL Script for enable change tracking at table level.<br><br>ALTER TABLE User  <br>ENABLE CHANGE_TRACKING  <br>WITH (TRACK_COLUMNS_UPDATED = ON ) </pre><p>Retention Period (Optional): By default, SQL Server retains change tracking information for specified days.</p><h3><strong>Monitor Change Tracking</strong></h3><p>After enabling Change Tracking, the system automatically maintains the change tracking information for the specified table(s). You can query the change tracking information periodically to synchronize changes with your application logic or for replication purposes.</p><p>Remember that Change Tracking captures minimal information about the changes (PK values and version numbers), so you may need additional queries to get the full details of the modified rows if required. Also, enabling Change Tracking on a table incurs some performance overhead, albeit relatively low, depending on the frequency of data changes.</p><p>Access Tracked table records:</p><pre>SELECT ct.* FROM CHANGETABLE(CHANGES &lt;dbname&gt;,&lt;lastversionno&gt;) ct</pre><p>Get Change Tracking Current Version:</p><pre>SELECT ISNULL(CHANGE_TRACKING_CURRENT_VERSION(), 0) as VersionCount</pre><p>Project Overview :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qdKTRmn7F0jKIZ71LOR7zA.png" /></figure><p>This database notification service is encapsulated within the SqlDBNotificationService&lt;TChangeTableEntity&gt; class. This generic class is designed to work with any table entity, allowing flexibility and easy integration into various applications. The generic type constraint ensures that the entity class must be a reference type with a default constructor, providing a consistent structure for handling the table data.</p><p>The SqlDBNotificationService class implements the IDBNotificationService&lt;TChangeTableEntity&gt; interface, making it easy to integrate into existing projects. It also exposes events for error handling and receiving changed data. Service monitors database ChangeTable for specified interval and returns changed records for specified table till the last time monitored.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*unPUdfY3ld_UhEIVzG8fOg.png" /></figure><p>Usage:</p><ol><li>Initializing the Service: Developers can create an instance of the SqlDBNotificationService class by providing the table name, database connection string, and an optional initial version for resuming monitoring.</li><li>Subscribing to Events: Applications can subscribe to the OnError and OnChanged events to handle errors and receive notifications when changes occur in the table.</li><li>Starting and Stopping Monitoring: The service can be started by calling the StartNotify() method, which initiates the polling process. The service can be stopped using the StopNotify() method.</li></ol><p>Features:</p><ol><li>Asynchronous Event-Based Model: The notification service employs a pub-sub model, meaning that when changes occur in the monitored table, the service sends asynchronous notifications to the registered subscribers (i.e., the application).</li><li>Query-Based Notifications: Unlike monitoring the entire table, our service allows the application to define a specific SQL query representing the data of interest. When relevant changes affect the query’s result set, a notification is triggered.</li><li>Low Resource Utilization: Our service optimizes resource consumption by avoiding constant polling. Instead, it leverages SQL Server’s Change Tracking, which efficiently tracks and delivers notifications only when necessary.</li><li>Flexible Initialization: Developers can specify the table to monitor, the connection string to the SQL Server database, an optional initial version for resuming monitoring, and a time interval for polling updates.</li><li>Error Handling and Resilience: The service includes robust error handling to ensure the application remains stable even in the face of unexpected exceptions. If an error threshold is reached, the service gracefully stops and notifies subscribers.</li><li>Easy Integration: The SqlDBNotificationService class implements the IDBNotificationService&lt;TChangeTableEntity&gt; interface, making it easy to integrate into existing projects. It also exposes events for error handling and receiving changed data.</li></ol><p>Reference Demo project is available <a href="https://github.com/jatinrdave/SQLEFTableNotification">here</a>.</p><p>Conclusion:</p><p>By utilizing the powerful combination of C#, SQL Server Change Tracking, and our custom SqlDBNotificationService, developers can easily add real-time database monitoring to their applications. The service&#39;s efficient event-driven model ensures timely and accurate updates without excessive resource consumption, enhancing application responsiveness and overall user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9512a2d14641" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>