arhamlabs/notification_handler

There is no license information available for the latest version (1.0) of this package.

1.0 2024-05-03 09:13 UTC

This package is not auto-updated.

Last update: 2024-10-04 11:30:49 UTC


README

This package will used for notifications.This package provides SLACL,EMAIL and FIREBASE Notification.

Installation

In order to install the package use the command specified below

composer require arhamlabs/notification_handler

Usage

Mail

For mail notification in config file alNotificationConfig.php enable following flags

'enable_notification' => true,

'notification_type' => [
        'email' => true
    ],

Once confing is enable then simply dispact array object to the MailNotificationHandlerJob.

Example-

use Arhamlabs\NotificationHandler\Jobs\MailNotificationHandlerJob;

 $body = array(
            /*errors you want to show*/
        );

        #Dispatch to job with the notification object
        $notificationObject = array();
        $notificationObject["body"] = json_encode($body);

        dispatch(new MailNotificationHandlerJob($notificationObject));

Slack

For slack notification in config file alNotificationConfig.php enable following flags

'enable_notification' => true,

'notification_type' => [
        'slack' => true
    ],

Once confing is enable then simply dispact array object to the SlackNotificationHandlerJob.

Example-

use Arhamlabs\NotificationHandler\Jobs\SlackNotificationHandlerJob;

 $body = array(
            /*errors you want to show*/
        );

        #Dispatch to job with the notification object
        $notificationObject = array();
        $notificationObject["body"] = json_encode($body);

        dispatch(new SlackNotificationHandlerJob($notificationObject));

Firebase

For slack notification in config file alNotificationConfig.php enable following flags

'enable_notification' => true,

'notification_type' => [
        'firebase' => true
    ],

for firebase notification it requires firebase json file.Simply add path into .env file.There are two ways to define firebase json path.If you are using s3 bucket then use S3_FIREBASE_JSON_PATH otherwise you can provide json file into public folder with LOCAL_FIREBASE_JSON_PATH.

S3_FIREBASE_JSON_PATH='s3 bucket path'


=========OR============

LOCAL_FIREBASE_JSON_PATH='path from public directory'

Example-

LOCAL_FIREBASE_JSON_PATH='firebase/request.json'

For send push notification on user device you require firebase token.

Example -

use Arhamlabs\NotificationHandler\Jobs\FirebaseNotificationHandlerJob;

 $tokens = [
            'token 1',
            'token 2',
            'token 3'
           ];
            $requestJson = [
                "title" => 'Test',
                "subtitle" => 'Testing',
                "data" => [
                    "redirection" => "/homeScreen",
                    "arguments" => json_encode(array(
                        'userUuid' => 'userUuid'
                    ))
                ]
            ];
            dispatch(new FirebaseNotificationHandlerJob($tokens, $requestJson));