<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Derrick</title>
    <description>The latest articles on DEV Community by Derrick (@derry606).</description>
    <link>https://dev.to/derry606</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1240419%2Fa3e21a95-df3a-4a33-96e4-db4bff5be4de.png</url>
      <title>DEV Community: Derrick</title>
      <link>https://dev.to/derry606</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/derry606"/>
    <language>en</language>
    <item>
      <title>Local Push Notifications and Firebase Notifications. Choose the most suitable for your Flutter application.</title>
      <dc:creator>Derrick</dc:creator>
      <pubDate>Sat, 13 Jan 2024 23:02:47 +0000</pubDate>
      <link>https://dev.to/derry606/local-push-notifications-and-firebase-notifications-choose-the-most-suitable-for-your-flutter-application-53fm</link>
      <guid>https://dev.to/derry606/local-push-notifications-and-firebase-notifications-choose-the-most-suitable-for-your-flutter-application-53fm</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Push notifications are essential for engaging users and keeping them informed about updates or events within a mobile application. For instance, if you want your app to notify users of a specific holiday or promos on your app or notify users who haven’t been active for a while. There are two main types of push notifications: local push notifications and Firebase notifications. In this document, we'll explore the technical aspects of both drawing conclusion on the right choice to choose for your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local Push Notifications
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;br&gt;
Local push notifications are notifications generated and scheduled directly on the user's device without relying on a backend server. These notifications are triggered by the application itself, and the delivery is managed locally on the device. Without internet access, local pus notifications’ processes still take place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Implementation
&lt;/h2&gt;

&lt;p&gt;1.** Notification API**&lt;br&gt;
Local push notifications are often implemented using platform-specific APIs. For example, on iOS, the UNNotificationRequest class can be used, while on Android, the NotificationManager class is commonly employed.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Farpoyhdrnn7cjqz0tbn3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Farpoyhdrnn7cjqz0tbn3.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
The fig. above shows a method that when called or accessed pushes notifications to users provided local push notification plugin is initialized in the root app in flutter for android.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Handling Notifications
&lt;/h2&gt;

&lt;p&gt;Developers need to implement handlers to respond to user interactions with local push notifications. This includes opening specific views or performing actions within the app when a notification is tapped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase Notifications
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;br&gt;
Firebase notifications leverage the Firebase Cloud Messaging (FCM) service to deliver messages to devices. These notifications are sent from a server (in this case, Firebase) and can be targeted to specific devices or user segments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Technical Implementation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Firebase Cloud Messaging&lt;/strong&gt;&lt;br&gt;
Integrating Firebase Notifications involves configuring the FCM SDK in your mobile app and handling the registration of devices to receive notifications.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn28ggozj35ciwmjz0qw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn28ggozj35ciwmjz0qw2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  WHICH ONE IS BEST FOR YOUR APPLICATION?
&lt;/h2&gt;

&lt;p&gt;Whether to use local push notifications or Firebase Cloud Messaging (FCM) depends on your specific requirements and use case. Let's consider some factors for each option:&lt;br&gt;
Local Push Notifications:&lt;br&gt;
• Offline Availability: Local notifications work even if the user is offline because they are scheduled and triggered by the local device.&lt;br&gt;
• Simplicity: Local notifications are generally simpler to implement since they don't require a server infrastructure.&lt;br&gt;
• Customization: You have more control over the appearance and behavior of local notifications on the device.&lt;br&gt;
• Resource Consumption: Local notifications consume fewer resources compared to remote notifications, as they don't involve network requests.&lt;br&gt;
Firebase Cloud Messaging (FCM):&lt;br&gt;
• Remote Delivery: Since it is a cloud service, FCM allows you to send notifications remotely from a server, making it suitable for scenarios where notifications are triggered by events on a server.&lt;br&gt;
• Multi-platform Support: FCM can be used to send notifications to both Android and iOS devices, making it suitable for cross-platform applications.&lt;br&gt;
• Rich Notifications: FCM allows you to send rich notifications containing images, buttons, etc.&lt;br&gt;
• Targeting: FCM provides advanced targeting options, allowing you to send notifications to specific devices or groups of devices.&lt;br&gt;
&lt;strong&gt;Considerations:&lt;/strong&gt;&lt;br&gt;
If your notification logic is purely based on client-side events and doesn't rely on a server or backend, local notifications might be sufficient.&lt;br&gt;
If you need to notify users based on server-side events, such as updates to their accounts or new content availability, FCM might be more suitable.&lt;br&gt;
For a combination of both local and remote notifications, you can implement logic to choose the appropriate notification type based on the event source (client or server).&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;Local push notifications and Firebase notifications serve different purposes. Local notifications are suitable for scenarios where server interaction is not necessary, while Firebase notifications offer a robust solution for server-initiated communication. Developers should choose the approach that aligns with their app's requirements and user engagement strategy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Query for you:
&lt;/h2&gt;

&lt;p&gt;Provided there is a use case scenario, an exercise routine app which has to send notifications to all users who have been inactive for more than a month, what push notifications is more suitable for deployment?&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>flutter</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
