Download the PHP package kobir/larapush-notification without Composer
On this page you can find all versions of the php package kobir/larapush-notification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package larapush-notification
Laravel Push Notification
Simple Laravel package for sending push notification to mobile devices (android, ios) using fcm http v1.
Requirements
- php version ^7.2 or higher
- Google API Client Library ^2.14.0 or higher
- Laravel version ^6.0 or higher
Installation
Use composer to download and install the package and its dependencies.
if you are facing dependency version conflict related issues please run
The package will automatically register its service provider.
To publish the package's configuration file run the following command
Configuration
After publishing the configuration, you can find the 'larapushnotification.php' as well as 'fcmCertificates' empty directory into the config folder.
The default configuration parameters for FCM are :
'priority' => 'normal'
,'certificate' => __DIR__ . '/fcmCertificates/fcm-admin-sdk.json',
'dry_run' => false,
'firebase_project_id' => 'FIREBASE_PROJECT_ID',
'token_cache_time' => 3500, //in seconds & must be <= 3500
'guzzle' => [],
You can dynamically update those values or adding new ones calling the method setConfig like so:
To generate a credentials fcm-admin-sdk json file for your service account:
- In the Firebase console, open Settings > Service Accounts.
- Click Generate New Private Key, then confirm by clicking Generate Key.
- Securely store the JSON file containing the key.
Usage
To instantiate the Push Notification class
By default it will use fcm as Push Service provider or you can pass service name if you want as like...
Now you may use any method that you need. Please see the all methods list.
setNotification
setNotification
method use to set the notification basic parameters, which you pass the values through parameter as an array.
Syntax
setData
setData
method use to set the additional message parameters like id, type sound click_action etc.., which you pass the values through parameter as an array.
Syntax
setProjectId
setProjectId
method use to set the Firebase Project ID of your App as a string.
Syntax
setJsonCredential
setJsonCredential
method use to set the path of credentials json file of your App.
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 url through parameter as a string.
Syntax
Not update the url unless it's really necessary.
setDevicesToken
setDevicesToken
method use to set the devices' tokens, which you pass the token through parameter either array for multiple tokens or string if single token.
Syntax
send
send
method is responsible for sending the push notification.
Syntax
getFeedback
getFeedback
method return the full notification response after sending a notification.
Syntax
getFailedDeviceTokens
getFailedDeviceTokens
method return the all devices' tokens that couldn't receive the notification or failed. Further you can make logic to your backend code for that device tokens.
Syntax
sendByTopic
sendByTopic
method use to send notification by topic. It also accepts the topic condition. more details here
If isCondition is true, $topic will be treated as an expression
Syntax
addDeviceTokenToTopic
addDeviceTokenToTopic
method use to add device into a topic. To add a new topic you need a unique topic name & all devices would you want to add this topic.
Syntax
removeDeviceTokenFromTopic
removeDeviceTokenFromTopic
method use to remove devices from a topic.
Syntax
getTopicInfo
getTopicInfo
method use to get all topics name associate with the provided device token.
Syntax
setTopicAddUrl
setTopicAddUrl
method sets the topic add url, which you pass the url through parameter as a string.
Syntax
Not update the url unless it's really necessary.
setTopicRemoveUrl
setTopicRemoveUrl
method sets the topic remove url, which you pass the url through parameter as a string.
Syntax
Not update the url unless it's really necessary.
setTopicInfoUrl
setTopicInfoUrl
method sets the topic info url, which you pass the url through parameter as a string.
Syntax
Not update the url unless it's really necessary.
Usage samples
This is the basic data-set for notification. Here send() method used for sending push notification.
Additional Payload
You can also pass the additional payload data by using setData() method
Get Notification Feedback
If you want get the failed device tokens use getFailedDeviceTokens() method as ...
If you want send the notification to only 1 device, you may pass the value as string.
Send Notification by Topic
or with using a condition:
Add Device Tokens into Topic
Remove Device Tokens from Topic
Get Topic Information
If you want to get how many topic associated with a device token then call this getTopicInfo() method with device_token parameter.
Contribution
Submitting issues and pull requests for bugs or new feature(s) requests are always welcome.
All versions of larapush-notification with dependencies
google/apiclient Version ^2.14.0|2.15.0
guzzlehttp/guzzle Version ^6.3|^7.0|^7.2
illuminate/support Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/notifications Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0