{"id":295,"date":"2017-01-09T07:55:27","date_gmt":"2017-01-09T07:55:27","guid":{"rendered":"https:\/\/www.appsted.com\/blog\/?p=295"},"modified":"2023-01-19T13:20:28","modified_gmt":"2023-01-19T13:20:28","slug":"how-to-master-the-firebase-notifications","status":"publish","type":"post","link":"https:\/\/www.appsted.com\/blog\/how-to-master-the-firebase-notifications\/","title":{"rendered":"How To Master The Firebase Notifications?"},"content":{"rendered":"<p style=\"text-align: center;\"><a href=\"https:\/\/www.appsted.com\/blog\/wp-content\/uploads\/2017\/01\/Firebase-Cloud-Messaging-.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-298\" title=\"Firebase-Cloud-Messaging-\" src=\"https:\/\/www.appsted.com\/blog\/wp-content\/uploads\/2017\/01\/Firebase-Cloud-Messaging-.jpg\" alt=\"Mobile app development company\" width=\"672\" height=\"378\" srcset=\"https:\/\/www.appsted.com\/blog\/wp-content\/uploads\/2017\/01\/Firebase-Cloud-Messaging-.jpg 672w, https:\/\/www.appsted.com\/blog\/wp-content\/uploads\/2017\/01\/Firebase-Cloud-Messaging--300x168.jpg 300w, https:\/\/www.appsted.com\/blog\/wp-content\/uploads\/2017\/01\/Firebase-Cloud-Messaging--500x281.jpg 500w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">With Firebase Notifications, the developer can send out target notifications to the single and specific device. All you need to do is to gain access to the registration token for the app instance of that device to provide token while composing and sending the notification to the Notification console. Sometimes, these Firebase Notifications can be a little bit confusing and there are several different ways to implement them but all these behave in a different manner. <\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">When it comes to enabling the Firebase Notifications there is a whole lengthy learning process which is both time-consuming and hectic. Well, in this blog you will come across a brief version of the implementation process. Moreover, this blog is especially for the amateur <\/span><\/span><a href=\"https:\/\/www.appsted.com\/hire-iphone-app-developers\/\"><strong><span style=\"color: #212121;\">iOS developers<\/span><\/strong><\/a><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\"><a title=\"iPhone application developers\" href=\"https:\/\/www.appsted.com\/hire-iphone-developers\" target=\"_blank\" rel=\"noopener\">,<\/a> who are looking for the quick guide on Firebase Notifications. <\/span><\/span><\/p>\n<h2 style=\"text-align: justify;\"><strong><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">Console Notifications<\/span><\/span><\/strong><\/h2>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">The easiest way to send and receive notifications with Firebase is by using the built-in console notifications. A simple notification will be displayed with the following components:<\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">The Title- which is the name of your app.<\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">The Text- it will be what message text you will put in the console.<\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">In case your app in running in the foreground then the notifications won\u2019t be displayed on the device. You can fix this issue by adding a FirebaseMessagingService that will efficiently handle this situation. But before, let\u2019s move on from the console to a command line tool to send notifications.<\/span><\/span><\/p>\n<h2 style=\"text-align: justify;\"><strong><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">Handling Notifications in Foreground<\/span><\/span><\/strong><\/h2>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">Whenever the app is closed or working in the background, the notifications are handled by the Google Service Process which takes care of display notifications as required, including the default click action and the notification icon. When the app is in the foreground, the received messages are processed by the app itself, and since there is no logic in place to handle it, nothing will happen. <\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">In reality, the onMessageReceive content will be a little bit more complex, and you will need different smart actions depending on the type of notification you want to display to the app users. The problem now you have is that the onMessageReceive is ONLY called when the app is in the foreground and if the app is in the background, the Google Services will take care of displaying your message. Instead of using notification messages, use \u201cdata\u201d. <\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">In the iOS-powered devices, you need to use the \u201cnotification\u201d object. It will be good if you pre-instruct your <\/span><\/span><a href=\"https:\/\/www.appsted.com\/hire-mobile-app-developers\/\"><strong><span style=\"color: #212121;\">mobile developer<\/span><\/strong><\/a><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\"> that you want to roll out different notification formats depending on the operating system. Just keep this thing in your mind that while registering the device to tokens in your system. <\/span><\/span><\/p>\n<h2 style=\"text-align: justify;\"><strong><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">Click Actions and other Parameters<\/span><\/span><\/strong><\/h2>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">While implementing actions by using \u201cclick_action\u201d parameter requires you to add an extra layer of filters in the iOS manifest for the each activity it will open. <\/span><\/span><\/p>\n<h3 style=\"text-align: justify;\"><strong><span style=\"color: #212121;\">Wrapping Up <\/span><\/strong><\/h3>\n<p style=\"text-align: justify;\"><span style=\"color: #212121;\"><span style=\"font-family: 'Droid Sans', sans-serif;\">Notifications sent via Firebase Console serves as the quickest way to send a notification but it lacks some options that developers need. Make sure you implement your Firebase Messaging Service from start. You should learn to send messages through Command Line. Along with that, you should also keep \u201cnotification\u201d JSON object for iOS and can avoid using \u201cdata\u201d. It will be good if you don&#8217;t use same solutions for both platforms.\u00a0<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With Firebase Notifications, the developer can send out target notifications to the single and specific device. All you need to do is to gain access to the registration token for the app instance of that device to provide token while composing and sending the notification to the Notification console. Sometimes, these Firebase Notifications can be a little bit confusing and there are several different ways to implement them but all these behave in a different manner. When it comes to enabling the Firebase Notifications there is a whole lengthy learning process which is both time-consuming and hectic. Well, in this blog you will come across a brief version of the implementation process. Moreover, this blog is especially for the amateur iOS developers, who are looking for the quick guide on Firebase Notifications. Console Notifications The easiest way to send and receive notifications with Firebase is by using the built-in console notifications. A simple notification will be displayed with the following components: The Title- which is the name of your app. The Text- it will be what message text you will put in the console. In case your app in running in the foreground then the notifications won\u2019t be displayed on &hellip; <a href=\"https:\/\/www.appsted.com\/blog\/how-to-master-the-firebase-notifications\/\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":298,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[10],"tags":[73,71,76,57,77,79,80,78],"class_list":["post-295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios-development","tag-hire-ios-developer","tag-hire-mobile-app-developer","tag-hire-mobile-developers","tag-ios-app-developers","tag-ios-app-development-services","tag-ios-develoeprs","tag-iphone-application-develoeprs","tag-iphone-application-development-services"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/posts\/295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/comments?post=295"}],"version-history":[{"count":5,"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/posts\/295\/revisions"}],"predecessor-version":[{"id":2105,"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/posts\/295\/revisions\/2105"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/media\/298"}],"wp:attachment":[{"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/media?parent=295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/categories?post=295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appsted.com\/blog\/wp-json\/wp\/v2\/tags?post=295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}