PHP code example of oscarcpv / aws-pinpoint-laravel-notification-channel

1. Go to this page and download the library: Download oscarcpv/aws-pinpoint-laravel-notification-channel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oscarcpv / aws-pinpoint-laravel-notification-channel example snippets




return [
    
    //...

    'aws_pinpoint' => [
        'region' => env('AWS_PINPOINT_REGION', 'us-east-1'),
        'key' => env('AWS_PINPOINT_KEY'),
        'secret' => env('AWS_PINPOINT_SECRET'),
        'application_id' => env('AWS_PINPOINT_APPLICATION_ID'),
        'sms' => [
            'sender_id' => env('AWS_PINPOINT_SMS_SENDER_ID')
        ],
    ],
];

use NotificationChannels\AwsPinpointChannel;

/**
 * Get the notification's delivery channels.
 *
 * @return array<int, string>
 */
public function via($notifiable)
{
    return ['broadcast', AwsPinpointChannel:class];
} 

use NotificationChannels\AwsPinpointMessage;

/**
 * Send SMS via AWS Pinpoint
 */
public function toAwsPinpoint($notifiable)
{
    return (new AwsPinpointMessage)
        ->body('Something cool')
        ->senderId('My Company')
        ->recipients($notifiable->phone)
        ->promotional();
} 

use Illuminate\Notifications\Notifiable;

class User extends Model
{
    use Notifiable;

    /**
     * Route notifications for the AWS Pinpoint channel.
     *
     * @return array|string|int
     */
    public function routeNotificationForAWSPinpoint()
    {
        return $this->phone;
    }
}

use NotificationChannels\AwsPinpointMessage;

/**
 * Send SMS via AWS Pinpoint
 */
public function toAwsPinpoint($notifiable)
{
    return new AwsPinpointMessage("Something cool");
}