Git Product home page Git Product logo

getui's Introduction

Laravel Or Lumen GeTui

基于 个推官方SDK for Laravel.

Installing

$ composer require octopusz/getui -v

Laravel

// config/app.php

    'providers' => [
        //...
        Ocotpus\GeTui\GeTuiServiceProvider::class,    //This is default in laravel 5.5
    ],

And publish the config file:

$ php artisan vendor:publish --provider=Ocotpus\\GeTui\\GeTuiServiceProvider

if you want to use facade mode, you can register a facade name what you want to use, for example GeTui:

// config/app.php

    'aliases' => [
        'GeTui' => Ocotpus\GeTui\Facade\GeTui::class,   //This is default in laravel 5.5
    ],

lumen

  • 在 bootstrap/app.php 中 82 行左右:
$app->register(Ocotpus\GeTui\GeTuiServiceProvider::class);

vendor/ocotpusz/getui/src/config/getui.php 拷贝到项目根目录/config目录下,并将文件名改成getui.php

configuration

// config/getui.php
   // APP_EVN     你的项目当前环境:测试 or 生产
    'app_env' => env('APP_ENV', 'development'),

   
    // The default default_client name which configured in `development` or `production` section
    //默认推送的客户端
    'default_client' => 'client',


    'development' => [
        'client' => [
            'appid' => 'your appid', //个推后后台获取相应app的参数
            'appkey' => 'your appkey',
            'appsecret' => 'your appsecret',
            'mastersecret' => 'your mastersecret',
            'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm',
        ],
        // other client   .....
    ],
    'production' => [
            'client' => [
                'appid' => 'your appid', //个推后后台获取相应app的参数
                'appkey' => 'your appkey',
                'appsecret' => 'your appsecret',
                'mastersecret' => 'your mastersecret',
                'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm',
            ],
            // other client   .....
    ],
    

Usage

Gateway instance:

use GeTui;
//针对单个或者多个用户推送
GeTui::push($deviceId, $data,true) //Using default default_client   推送给默认的客户端
GeTui::toClient('CLIENT NAME')->push($deviceId, $data)  // CLIENT NAME is key name of `development` or `production`  configuration.  //自定义发送的客户端  

// 针对整个app所有人推送
GeTui::pushToApp($data,true) ////Using default default_client  
GeTui::toClient('CLIENT NAME')->pushToApp($data)  // GATEWAY NAME is key name of `development` or `production`  configuration.

Example:

    $deviceId = '111111111111111';
   // 多个push对象device_id 用数组传入
//   $deviceId = [
//            '111111111111111',
//            '222222222222222',
//           ];        

   $data = [
                'url' => '推送的url',
                'title' => '这是个调皮的推送',
                'content' => '想啥有啥',
            ];
$res = \GeTui::push($deviceId, $data,true); //Using default default_client
print_r($res)

License

MIT

getui's People

Stargazers

NiceNight avatar octopus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.