定制 liliom/laravel-firebase 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

liliom/laravel-firebase

最新稳定版本:v1.0.1

Composer 安装命令:

composer require liliom/laravel-firebase

包简介

Laravel FCM (Firebase Cloud Messaging) Notification Channel

README 文档

README

This package makes it easy to send notifications using Firebase Cloud Messaging (FCM) with Laravel Notification Channel.

Installation

This package can be installed through Composer.

composer require liliom/laravel-firebase

If you don't use Laravel 5.5+ you have to add the service provider manually

// config/app.php
'providers' => [
    ...
    Liliom\Firebase\FirebaseServiceProvider::class,
    ...
];

Now add you Firebase API Key in config/services.php.

return [
	....
    'firebase' => [
        'key' => ''
    ],
    ....
];

Usage

Les's create a notification using artisan commend:

php artisan make:notification FirebaseNotification

Now you can use firebase channel in your vie() mothod.

public function via($notifiable)
{
    return ['firebase'];
}

Add a pubilc method toFirebase($notifiable) to your notification class, and return an instance of FirebaseMessage:

public function toFirebase($notifiable)
{
    return (new \Liliom\Firebase\FirebaseMessage)
        ->notification([
            'title' => 'Notification title',
            'body' => 'Notification body',
            'sound' => '', // Optional
	    'icon' => '', // Optional
	    'click_action' => '' // Optional
        ])
        ->setData([
	    'param' => 'zxy' // Optional
	])
	->setPriority('high'); // Default is 'normal'
}

Available methods:

  • setData: To Set data.
  • setPriority: To Set priority.
  • setTimeToLive: To Set time_to_live.
  • setCollapseKey: To Set collapse_key.
  • setNotification: To Set notification.
  • setCondition: To Set condition.
  • setContentAvailable: To Set content_available.
  • setMutableContent: To Set mutable_content.
  • setPackageName: To Set restricted_package_name.

When sending to specific device(s), make sure your notifiable entity has routeNotificationForFirebase method defined:

Note: You can send to many devices by return an array of tokens.

/**
 * Route notifications for Firebase channel.
 *
 * @return string|array
 */
public function routeNotificationForFirebase()
{
    return $this->device_tokens;
}

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 26.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 2
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固