phuocdaivl/azure-noti

Push notification with Azure Notification Hub Service

1.0.0 2019-09-24 06:39 UTC

This package is auto-updated.

Last update: 2024-05-25 12:43:46 UTC


README

Create Registration and send notification

Latest Version on Packagist Software License Build Status Total Downloads

Download & Install

composer require phuocdaivl/azure-noti

Add service provider

Add the service provider to the providers array in the config/app.php config file as follows:

'providers' => [

    ...

    DaiDP\AzureNoti\Providers\AzureNotiServiceProvider::class,
]

Well done.

Basic use:

use \DaiDP\AzureNoti\PlatformFactory;

$endpoint = PlatformFactory::getEndpoint(PlatformFactory::ENDPOINT_FCM);

Methods

The following methods are available on the PlatformEndpoint instance.

createRegistration()

Create or update Registration ID

$fcmRegistration = 'fPDLWe0fKpY:APA91bHocOJCoKx5GV9ETT0bUmJDQAWiT8Ql4zFB5Ycr_sAm6tQ6aOmcTnGC3LwiyCa-beaXZoWrkxWTDvBkUVE8Th_XWNQUdzeNlbZ2MmT-lVj4Gxe4baoqVYYtmoAvZvZxghPZirOo';
$tags = ['tag1', 'tag2'];
$result = $endpoint->createRegistration($fcmRegistration, $tags);

sendNativeNotification()

Set new password for account

$message = new \DaiDP\AzureNoti\Message([
    'title' => 'Test push notification',
    'body' => 'great match!'
]);
$fcmRegistration = 'fPDLWe0fKpY:APA91bHocOJCoKx5GV9ETT0bUmJDQAWiT8Ql4zFB5Ycr_sAm6tQ6aOmcTnGC3LwiyCa-beaXZoWrkxWTDvBkUVE8Th_XWNQUdzeNlbZ2MmT-lVj4Gxe4baoqVYYtmoAvZvZxghPZirOo';
$result = $endpoint->sendNativeNotification($device, $message);