astrotomic/notifynder-sender-messagebird

此包已被弃用且不再维护。作者建议使用 laravel-notification-channels/messagebird 包代替。

Notifynder 包的 MessageBird 发送器。

1.2.0 2017-02-09 13:24 UTC

This package is not auto-updated.

Last update: 2019-10-22 12:01:49 UTC


README

GitHub release GitHub license GitHub issues Total Downloads

StyleCI

Code Climate

Slack Team Slack join

文档: Notifynder 文档

安装

步骤 1

composer require astrotomic/notifynder-sender-messagebird

步骤 2

将以下字符串添加到 config/app.php

提供者数组

Astrotomic\Notifynder\NotifynderSenderMessageBirdServiceProvider::class,

步骤 3

将以下数组添加到 config/notifynder.php

'senders' => [
    'messagebird' => [
        'access_key' => '',
        'callbacks' => [
            'sms' => function(\Astrotomic\Notifynder\Senders\Messages\SmsMessage $message, \Fenos\Notifynder\Models\Notification $notification) {
                return $message
                    ->from(...)
                    ->to(...)
                    ->body($notification->getText());
            },
            'voice' => function(\Astrotomic\Notifynder\Senders\Messages\CallMessage $message, \Fenos\Notifynder\Models\Notification $notification) {
                return $message
                    ->from(...)
                    ->to(...)
                    ->body($notification->getText())
                    ->lang('en-gb')
                    ->male();
            },
        ],
        'store' => false, // wether you want to also store the notifications in database
    ],
],

在您的 app/Providers/AppServiceProvider.php 中注册发送器回调

<?php
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Astrotomic\Notifynder\Senders\MessageBirdSmsSender;
use Astrotomic\Notifynder\Senders\Messages\SmsMessage;
use Astrotomic\Notifynder\Senders\MessageBirdCallSender;
use Astrotomic\Notifynder\Senders\Messages\CallMessage;
use Fenos\Notifynder\Builder\Notification;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        app('notifynder.sender')->setCallback(MessageBirdSmsSender::class, function (SmsMessage $message, Notification $notification) {
            return $message
                ->from('0123456789')
                ->to('9876543210')
                ->text($notification->getText());
        });
        
        app('notifynder.sender')->setCallback(MessageBirdCallSender::class, function (CallMessage $message, Notification $notification) {
            return $message
                ->from('0123456789')
                ->to('9876543210')
                ->lang('en-us')
                ->male()
                ->text($notification->getText());
        });
    }
}