Download the PHP package paxha/laravel-push-notifications without Composer

On this page you can find all versions of the php package paxha/laravel-push-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-push-notifications

PushNotification Package

Build Status Total Downloads Latest Stable Version License

This is an easy to use package to send push notification.

Push Service Providers Available:

Installation

Laravel version below 5.8

type in console:

Laravel 5.8/6 and higher

type in console:

The package will automatically register its service provider.

Publish the package's configuration file to the application's own config directory

Go to laravel facade sample directly.

Configuration

After publishing the configuration, you can find the Push service config in config/pushnotification.php

The default configuration parameters for GCM and FCM are :

You can dynamically update those values or adding new ones calling the method setConfig like so:

The default configuration parameters for APN are:

(Make sure to set dry_run to true if you're using development *.pem certificate, and false for production)

Also you can update those values and add more dynamically

Even you may update the url of the Push Service dynamically like follows:

Not update the url unless it's really necessary.

You can specify the number of client-side attempts to APN before giving up. The default amount is 3 attempts. You can override this value by specifying connection_attempts in setConfig() assoc-array. Keep in mind the default number of requested attempts is 3.

If you prefer to retry indefinitely, set connection_attempts to zero.

$push->setConfig([
    'passPhrase' => 'NewPass',
    'custom' => 'MycustomValue',
    'connection_attempts' => 0,
    'dry_run' => true
]);

Usage

By default it will use GCM as Push Service provider.

For APN Service:

For FCM Service:

Now you may use any method that you need. Please see the API List.

API List

Only for Gcm and Fcm

Only for Fcm

Go to Usage samples directly.

setService

setService method sets the push service to be used, which you pass the name through parameter as a string.

Syntax

setMessage

setMessage method sets the message parameters, which you pass the values through parameter as an array.

Syntax

setApiKey

Only for gcm and fcm

setApiKey method sets the API Key of your App, which you pass the key through parameter as a string.

Syntax

setDevicesToken

setDevicesToken method sets the devices' tokens, which you pass the token through parameter as array or string if it was only one.

Syntax

send

send method sends the notification.

Syntax

getFeedback

getFeedback method gets the notification response, which you may use it chaining it to send method or call it whenever after sending a notification.

Syntax

getUnregisteredDeviceTokens

getUnregisteredDeviceTokens method gets the devices' tokens that couldn't receive the notification because they aren't registered to the Push service provider. You may use it chaining it to send method or call it whenever after sending a notification.

Syntax

setConfig

setConfig method sets the Push service configuration, which you pass the name through parameter as an array.

Syntax

setUrl

setUrl method sets the Push service url, which you pass the name through parameter as a string.

Syntax

Not update the url unless it's really necessary.

sendByTopic

Only for fcm

sendBytopic method sends a message by topic. It also accepts the topic condition. more details here

If isCondition is true, $topic will be treated as an expression

Syntax

Usage samples

You can chain the methods.

GCM sample:

APN sample:

or do it separately

If you want send the notification to only 1 device, you may pass the value as string.

Send the Notification

Method send() can be also chained to the above methods.

Send the Notification by Topic (FCM only)

or with a condition:

Understanding Gcm and Fcm Message Payload

Notification Message

Add a notification key when setting the message in setMessage method. like follows:

You may add some extra payload adding a data key when setting the message in setMessage method.

Data Message

By default, this package sends the notification as Data Message. So no need to add a data key.

The above example is like you were sending the following:

For more details, have a look at gcm/fcm notification paypload support and the concept options

Getting the Notification Response

If you want to get the push service response, you can call the method getFeedback:

Or again, chain it to the above methods:

It will return an object with the response.

APN Server Feedback and package Feedback

Any time you send a notification, it will check if APN server has any feedback for your certificate. If so, the responses are merged to our feedback like below:

Get Unregistered Devices tokens

After sending a notification, you may retrieve the list of unregistered tokens

This method returns an array of unregistered tokens from the Push service provider. If there isn't any unregistered token, it will return an empty array.

Laravel Alias Facade

After register the Alias Facade for this Package, you can use it like follows:

It would return the Push Feedback of the Notification sent.

Notification channels

Formatting Push Notifications

If a notification supports being sent as an push message, you should define toApn and/or toFcm/toGcm methods on the notification class. This method will receive a $notifiable entity and should return a Edujugon\PushNotification\Messages\PushMessage instance:

Customizing The Title and Body

Customizing The Notification Sound

Customizing The Badge Number

Passing Service Config

Add it to the notification channels

Don't forget the use statement at the top of the class

Routing Push Notifications

Just define routeNotificationForApn and/or routeNotificationForFcm/routeNotificationForGcm methods on the entity


All versions of laravel-push-notifications with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3|^8.0
guzzlehttp/guzzle Version ^6.3 || ^7.0.1
illuminate/support Version ~5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
illuminate/notifications Version ~5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package paxha/laravel-push-notifications contains the following files

Loading the files please wait ....