jimchen/umeng

友盟推送

1.2.1 2019-11-19 02:24 UTC

This package is auto-updated.

Last update: 2022-05-19 09:32:46 UTC


README

友盟推送SDK

StyleCI build status FOSSA Status

996.icu LICENSE HitCount

Installing

$ composer require jimchen/umeng -vvv

配置

在使用本扩展之前,你需要去 友盟+ 注册账号,然后创建应用,获取应用的 Key 和秘钥。

使用

require __DIR__ .'/vendor/autoload.php';

use Hedeqiang\UMeng\Android;
use Hedeqiang\UMeng\IOS;

// Android 
$config = [
    'appKey' => '5b1df1**************',
    'appMasterSecret' => 'i7tzdarsw************',
    'production_mode' => true,
];
// IOS 
$ios_config = [
    'appKey' => '5b1df0d1************',
    'appMasterSecret' => 'fa9ry9kd*********',
    'production_mode' => true,
]

$android = new Android($config));

$ios = new IOS($ios_config);

Android

customizedcast消息发送示例

$params = [
    'alias_type' => 'APP',
    'alias' => 1,
    "ticker" => "测试提示文字",
    "title" => "测试标题",
    "text" => "测试文字描述",
    "after_open" => "go_app",
    "description" => "测试广播通知-Android",
];

$response = $android->sendAndroidCustomizedcast($params);

broadcast消息发送示例

$params = [
    "ticker" => "测试提示文字",
    "title" => "测试标题",
    "text" => "测试文字描述",
    "after_open" => "go_app",

];
$extra = [
    'key1' => 'val1',
    'key2' => 'val2',
];

$response = $android->sendAndroidBroadcast($params, $extra);

unicast消息发送示例

$params = [
    "device_tokens" => "测试提示文字",
    "display_type" => "notification", // message:消息 notification:通知
    //"custom" => '自定义custom',
    //以下内容为 notification  必填项 
    "ticker" => "测试提示文字",
    "title" => "测试标题",
    "text" => "测试文字描述",
    "after_open" => "go_app",

];
//可选项
$extra = [
    'key1' => 'val1',
    'key2' => 'val2',
];

$response = $android->sendAndroidUnicast($params, $extra);

filecast消息发送示例

$params = [
    "ticker" => "测试提示文字",
    "title" => "测试标题",
    "text" => "测试文字描述",
    "after_open" => "go_app",
];
//
$content = "aa" . "\n" . "bb";

$response = $android->sendAndroidFilecast($params, $content);

groupcast消息发送示例

$params = [
    "ticker" => "测试提示文字",
    "title" => "测试标题",
    "text" => "测试文字描述",
    "after_open" => "go_app",
];
//

$filter = [
    'where' => [
        'and' => [
            'tag' => 'test',
            'tag1' => 'test2',
        ],
    ],
];

$response = $android->sendAndroidGroupcast($filter, $params);

sendAndroidCustomizedcastFileId 消息示例

 $params = [
    "ticker" => "测试提示文字",
    "title" => "测试标题",
    "text" => "测试文字描述",
    "after_open" => "go_app",
    'alias_type' => 'APP',
];
$content = "aa" . "\n" . "bb";

$response = $android->sendAndroidCustomizedcastFileId($params, $content);

IOS

broadcast消息发送示例

$params = [
    'alert' => [
        'title' => 'title',
        'body' => 'body',
    ],  //字符串或者JSON
    "description" => "测试广播通知-iOS"
];
$customized = [
    'key' => 'jey',
]; //可选
$response = $ios->sendIOSBroadcast($params, $customized);

unicast消息发送示例

$params = [
    'device_tokens' => 'token',
    'alert' => [
        'title' => 'title',
        'body' => 'body',
    ],  //字符串或者JSON
    "description" => "测试单播消息-iOS"
];
$customized = [
    'key' => 'jey',
]; //可选
$response = $ios->sendIOSUnicast($params, $customized);

filecast消息发送示例

$params = [
    'device_tokens' => 'token',
    'alert' => [
        'title' => 'title',
        'body' => 'body',
    ],  //字符串或者JSON
    "description" => "测试filecast文件通知-iOS"
];
$content = "aa" . "\n" . "bb";

$response = $ios->sendIOSFilecast($params, $content);

groupcast消息发送示例

$params = [
    'alert' => [
        'title' => 'title',
        'body' => 'body',
    ],  //字符串或者JSON
    "description" => "测试组播通知-iOS"
];
$filter = [
    'where' => [
        'and' => [
            'tag' => 'test',
            'tag1' => 'test2',
        ],
    ],
];

$response = $ios->sendIOSGroupcast($filter, $params);

customizedcast消息发送示例

$params = [
    'alert' => [
        'title' => 'title',
        'body' => 'body',
    ],  //字符串或者JSON
    'alias_type' => 'APP',
    'alias' => 1,
    "description" => "测试alias通知-iOS"
];


$response = $ios->sendIOSCustomizedcast($params);

参考

工具

68747470733a2f2f757079756e2e6c61726176656c636f64652e636e2f75706c6f61642f4a6574427261696e732f6a6574627261696e732d747261696e696e672d706172746e65722e706e67

License

MIT

FOSSA Status