定制 matriphe/gcm 二次开发

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

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

matriphe/gcm

最新稳定版本:1.3

Composer 安装命令:

composer require matriphe/gcm

包简介

Simple GCM push using Guzzle.

README 文档

README

Send GCM Push notification using Guzzle. Make sure you have the GCM Api key and could get Device ID and generate GCM ID.

Compatibility

Works with Laravel 5.0.

Installation

Open composer.json and require this line below.

"matriphe/gcm": "dev-master"

Or you can run this command from your project directory.

composer require "matriphe/gcm:dev-master"

Laravel Installation

Open the config/app.php and add this line in providers section.

'Matriphe\Gcm\GcmServiceProvider'

Still in config/app.php, add this line in alias section.

'Gcm' => 'Matriphe\Gcm\GcmFacade'

Publish Configuration

To control the configuration, you have to publish the configuration file.

php artisan vendor:publish

After running this command, there will be config/gcm.php and resources/views/vendor/gcm/form.blade.php files.

Please fill the appKey section in the config/gcm.php.

Usage

Just use the push($device_id, $gcm_id, $subject, $message, $extras = []) function and it will push the message to GCM.

The return of the function is object.

Example

$device_id = '30C89D80C48E96AE';
$gcm_id = 'APA91bGfw8y8DG6CL1BOraVDJyYXUU82rwzbJjnR5PppIcSE7HYgQSvxiSHMJN7zYiCC9CLGNHLiWMxUD22JrlSmvMkaJiUgCsMOvHk0BPeWmvGJu4oHAa1KUm9D5ngdcFNNUwJQ7ttB6VW0F575rhQ2ow56ACM1Yg';
$subject = 'Test Push Subject';
$message = 'This is the message that will be shown in notification.';
$extras = [
    'id' => 21,
    'user' => 'motherfather',
];
Gcm::push($device_id, $gcm_id, $subject, $message, $extras = [])

Output

stdClass Object
(
    [multicast_id] => 6100993858981303466
    [success] => 1
    [failure] => 0
    [canonical_ids] => 0
    [results] => Array
        (
            [0] => stdClass Object
                (
                    [message_id] => 0:1434034071184625%9747e1a6f9fd7ecd
                )

        )

)

Test

It has routes, so you can go to /matriphe/gcmon your URL and try to send the GCM notification.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-11