PHPackages                             caherrera/laravel-notifications-infobip-omni - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. caherrera/laravel-notifications-infobip-omni

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

caherrera/laravel-notifications-infobip-omni
============================================

A custom Laravel notifications channel for Infobip API OMNI. Based on princeton255/laravel-notifications-infobip

1.1.3(5y ago)0663[1 issues](https://github.com/caherrera/laravel-notifications-infobip-omni/issues)MITPHPPHP ^7.1

Since Feb 12Pushed 5y agoCompare

[ Source](https://github.com/caherrera/laravel-notifications-infobip-omni)[ Packagist](https://packagist.org/packages/caherrera/laravel-notifications-infobip-omni)[ RSS](/packages/caherrera-laravel-notifications-infobip-omni/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (7)Versions (7)Used By (0)

Infobip Notifications Channel for Laravel 5.5+
==============================================

[](#infobip-notifications-channel-for-laravel-55)

[![Latest Stable Version](https://camo.githubusercontent.com/334bc057f48048ba49921b0cf40078e644badffbc008d1fcd1d562b70f61dab7/68747470733a2f2f706f7365722e707567782e6f72672f6361686572726572612f6c61726176656c2d6e6f74696669636174696f6e732d696e666f6269702f762f737461626c65)](https://packagist.org/packages/caherrera/laravel-notifications-infobip)[![License](https://camo.githubusercontent.com/91ccee3cd69f8567749785ccd1326b2f05d8aae3c45b0d948d3bb30fbea91411/68747470733a2f2f706f7365722e707567782e6f72672f6361686572726572612f6c61726176656c2d6e6f74696669636174696f6e732d696e666f6269702f6c6963656e7365)](https://packagist.org/packages/caherrera/laravel-notifications-infobip)[![Total Downloads](https://camo.githubusercontent.com/185cd46fdf794bd3002b7a3715d13a78aefd733e77cfe69710317e04b857cef9/68747470733a2f2f706f7365722e707567782e6f72672f6361686572726572612f6c61726176656c2d6e6f74696669636174696f6e732d696e666f6269702f646f776e6c6f616473)](https://packagist.org/packages/caherrera/laravel-notifications-infobip)

This package makes it easy to send Sms notifications using [Infobip service](https://dev.infobip.com/) with Laravel 5.5 and above.

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up your Infobip account](#setting-up-your-infobip-account)
- [Usage](#usage)
    - [Available Message methods](#available-message-methods)
- [Examples](#examples)
    - [Dispatching the notification](#dispatching-the-notification)
    - [Example Notification class](#example-notification-class)
    - [Example Notifiable class](#example-notifiable-class)
- [Testing](#testing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require caherrera/laravel-notifications-infobip
```

### Setting up your Infobip account

[](#setting-up-your-infobip-account)

Add this settings to `config/services.php`:

```
// config/services.php
...
    'infobip' => [
        'auth'        => env('INFOBIP_AUTH','basic'),
        'username'    => env('INFOBIP_USERNAME'),
        'password'    => env('INFOBIP_PASSWORD'),
        'baseUrl'     => env('INFOBIP_BASE_URL'),
        'apikey'      => env('INFOBIP_PUBLIC_KEY'),
        'scenarioKey' => env('INFOBIP_SCENARIO_KEY'),
    ],
...
```

To change `Base URL` to personal use this ([See more](https://dev.infobip.com/getting-started/base-url))

Usage
-----

[](#usage)

Now you can use the channel in your `via()` method inside the notification:

```
use NotificationChannels\Infobip\InfobipChannel;
use NotificationChannels\Infobip\InfobipMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [InfobipChannel::class];
    }

    public function toInfobip($notifiable)
    {
    	$message = new InfobipMessage();
		$message->setTemplateName("infobip_test_hsm");
		$message->setTemplateNamespace("whatsapp:hsm:it:infobip");
		$message->setTemplateData(["Jhon","Snow"]);
		$message->setLanguage("es");
        return $message;
    }
}
```

In order to let your Notification know which phone are you sending to, the channel will look for the `phone_number` attribute of the Notifiable model. If you want to override this behaviour, add the `routeNotificationForInfobip` method to your Notifiable model.

```
public function routeNotificationForInfobip()
{
    return '+1234567890';
}
```

### Available Message methods

[](#available-message-methods)

#### InfobipMessage

[](#infobipmessage)

- `setTemplateName('')`: Accepts a string value.
- `setTemplateNamespace('')`: Accepts a string value.
- `setTemplateData(['','',...])`: Accepts an array of string.
- `setLanguage('')`: Accepts a string value

Examples
--------

[](#examples)

### Dispatching the notification

[](#dispatching-the-notification)

#### A. Using Laravel's notification facade

[](#a-using-laravels-notification-facade)

```
use App\Notifications\ExampleInfobipNotification;
use Illuminate\Support\Facades\Notification;

Notification::send($user, new ExampleInfobipNotification());

// where $user implements `Illuminate\Notifications\Notifiable` trait
```

#### B. Using the `notify()` method from `Notifiable` trait

[](#b-using-the-notify-method-from-notifiable-trait)

```
use App\Notifications\ExampleInfobipNotification;

$user->notify(new ExampleInfobipNotification($invoice));
```

### Example Notification class

[](#example-notification-class)

```
