[PAID] FCM: Receive Push Notifications with Firebase Cloud Messaging [$10 or INR 701]

1.Introduction

Description: Using this extension you can receive Push Notifications with FCM's latest SDK (24.0.0).
Latest Version: 2
Released: 2023-10-29T18:30:00Z
Last Updated: 2024-06-17T18:30:00Z
Aix size: 480 kB

2. Blocks

image

3. Docs

Events

GotPermissionResultEvent raised after user grants/denies Notification permission
isGranted | boolean
MessageReceivedEvent raised when message is received. No notification is shown for messages.
data | dictionary
NotificationReceivedEvent raised when notification is received while app is in foreground. A notification is shown to user in system tray.
id | text
title | text
body | text
data | dictionary
SubscribeSuccessfulE ivent raised if subscribe was successful
topic | text
UnsubscribeSuccessfulEvent raised if unsubscribe was successful
topic | text
ErrorOccurredEvent raised whenever an error occurrs. Most of the methods raise this event in case of error.
method | text
errorMsg | text
GotTokenEvent raised after getting FCM token
token | text
GotDataEvent raised when current screen has been opened by clicking notification. This event is raised automatically.
data | dictionary

Methods

AskNotificationPermissionAsks notification permission which is required on Android 13 and above
IsPermissionGrantedReturn whether user has granted Notification permission or not
ClearNotificationClear notification from system tray
id | number
InitInitialize Firebase Messaging Client with provided credentials. You need to call this method only once and then extension will auto init client itself.
projectId | text
apiKey | text
appId | text
senderId | text
IsInitializedReturns whether FCM has been initialized or not
SubscribeSubscribe to given topic to receive notifications
topic | text
RegisterForNotifClickRegisters screen which will be opened when user clicks on notification which is shown while app is in foreground. Notifications which are shown when app is not opened, will always open Screen1.
screen | text
startValue | text
RetrieveDataRetrieves content of notification which opened/resumed current screen.Response is Dictionary.
RetrieveBgMessagesRetrieve dictionary of messages which were received when app was not running.
ClearBgMessagesClear stored background messages.
UnsubscribeUnsubscribe from the given topic
topic | text
GetTokenGets user's FCM token which can be used to send individual notifications

Properties

ImportanceSets importance of notification channel
Property Type : write-only
Accepts : text
SmallIconSets small icon shown in notification. If not specified then app's icon is shown.
Property Type : write-only
Accepts : text

4. Usages

First initialize FCM Client. You need to call Init method once and next time it would be auto initialized.
image

Ask for notification permission
image
Required on Android 13 and above

Now subscribe to a topic
image

image

If subscription was successful then you can send a notification/message to users who have subscribed to topic
Use FcmSender extension for sending notifications and messages

User receives notifications and clicks on it
There can be two scenarios here:-

  1. App in foreground ie. being used by user
    Notification will open registered screen.
    image

GotData even will be raised upon screen initialization if screen opened through notification.


You can obtain data from RetrieveData method also.

  1. App not opened by user.
    Notification click will open registered screen (or Screen1 if not set) and GotData event will be raised. If no screen is registered then Screen where FCM extension has been initialized is automatically registered.

Retrieve all received messages
Old method

New method
image

5. Purchase

https://sunnythedeveloper.in/paid-fcm-send-and-receive-push-notifications-with-firebase-cloud-messaging-10-or-inr-701/

6. Demo


7. Updates

ChangeLog Version 1.1

[PAID] FCM: Receive Push Notifications with Firebase Cloud Messaging [$10 or INR 701] - #3 by vknow360

ChangeLog Version 1.2

[PAID] FCM: Receive Push Notifications with Firebase Cloud Messaging [$10 or INR 701] - #4 by vknow360

ChangeLog Version 1.3

[PAID] FCM: Receive Push Notifications with Firebase Cloud Messaging [$10 or INR 701] - #5 by vknow360

ChangeLog Version 1.4

[PAID] FCM: Receive Push Notifications with Firebase Cloud Messaging [$10 or INR 701] - #6 by vknow360

ChangeLog Version 2

[PAID] FCM: Receive Push Notifications with Firebase Cloud Messaging [$10 or INR 701] - #9 by vknow360

Thank you.
Hope it helps!

4 Likes

Setup video:

ChangeLog Version 1.1

  • Added ClearNotification block

  • Added feature to store all messages in Tiny DB with tag as timestamp
    Set namespace to FCM_DATA to retrieve those messages

  • Fixed inconsistency in SendNotificationToTokens and SendMessageToTokens blocks

  • Some internal changes to make future improvements easier to adapt

ChangeLog Version 1.2

  • Removed SoundOn property

  • Custom Notification sound feature
    Beta tested by @Franklin_Lopez

To send a notification with custom sound, upload mp3 file to assets and send payload like this:

{\"notification\": {\"body\": \"this is a body\", \"default\": \"this is a title\", \"sound2\":\"default\",\"icon\":\"https://res.cloudinary.com/andromedaviewflyvipul/image/upload/c_scale,h_20,w_20/v1571472765/ktvu4bapylsvnykoyhdm.png\"},\n    \"priority\": \"high\",\n    \"data\": {\n      \"click_action\": \"FCM_MESSAGE\",\n      \"id\": \"1\",\n      \"status\": \"done\"\n    },\n    \"to\": \"/topics/FCMTEST\""}

Value for sound2 key can be file name ( like test for test.mp3 ) or none for no sound or default for default notification sound.
This key must be present in notification payload otherwise no sound will be played.

Aix size is 500 kb now.

ChangeLog Version 1.3

  • Compatible with FSA extension
    Tested by @Franklin_Lopez
  • Aix size reduced to 476 kb
1 Like

ChangeLog Version 1.4

  • New Blocks
    image
    You can retrieve messages which were received when app was not running. Returns Dictionary where timestamp is key and value is message content.

  • Behavior Changes
    i) Clicking fcm notification when app is in foreground will open registered screen (or Screen1 if not set), but previous instance of Screen will be created if that screen is already running instead will be resumed.
    ii) Now notifications received in background also use small icon. (Earlier app icon was shown)

  • Internal Changes
    Important changes to adapt HTTP v1 Api for sending notifications

  • Aix size reduced to 468 kb

Notification (and Message) sending API has been removed (deprecated on June 20, 2023 ) by Firebase and can stop working anytime.
A separate extension for sending notifications will be released soon and it will be a PAID extension.

Receiving notifications will continue working without any issue.

Recommended to use.

ChangeLog Version 2 :warning:

  • Updated Fcm SDK version to 24.0.0

  • Removed Notification Sending blocks (Migrate to FcmSender extension)

  • Removed Notification Sound property

  • Fixed notification click issue when no Screen was registered for open

  • Resuming Screen from Notification Click also invokes GotData event

  • Added permission handling method and event
    image

  • Added method parameter to Error Occurred event
    image

1 Like

i want to avail, pls guide me

ChangeLog Version 2.1 :loudspeaker: :loudspeaker:

  • Minor bug fixes
  • Improved custom notification algorithm
  • Added notification link feature
    If link tag is sent in data then that url is opened upon notification click.

Large icon and set vibration

  1. Any suggestions for large icon?
    Max pixels? jpg or png? black and white or color? square/rectangular or circle? Max size(KB)?
    I tried with some images but it doesn’t display them.
    For example I tried with color icons with circle shape *.png 160x160 pixels without success.

No problem with the small icon instead

  1. Does anyone know how to set vibration to on?