当前位置:网站首页>Laravel Aurora push
Laravel Aurora push
2022-06-25 04:52:00 【Kiway.】
Laravel Aurora push
- composer Reference Aurora files
composer require jpush/jpush
This operation may lead to the problem that the package is not imported , View reasons , Because php.ini Configuration problem of , Or because composer The problem of , When I quote php.ini Of limit Limit impulse of 256MB Changed to -1, then composer require jpush/jpush And then continue composer update once .
Quote it jpush After the package , stay vendor Folder can be found , Put... Directly jpush It's no use throwing folders in , Not through composer require jpush/jpush Set up laravel Many places have not established a good connection with the aurora .
The main code can be written in one file , Then other files can reference this file to call methods .
The code is as follows :
<?php
namespace App\Http\Controllers\Api;
use JPush\Client as JPushClient;
use Illuminate\Http\Request;
class JpushController extends BaseController
{
public function __construct(){
$this->request = request();
$this->app_key="****";
$this->master_secret="*****";
$this->client=new JPushClient($this->app_key, $this->master_secret);
}
/** =================================================== Calling method =================================================== */
// obtain alias and tags
public function getDevices($registrationID){
$result = $this->client->device()->getDevices($registrationID);
return $result;
}
// add to tags
public function addTags($registrationID, $tags){
$result = $this->client->device()->addTags($registrationID,$tags);
return $result;
}
// remove tags
public function removeTags($registrationID, $tags){
$result = $this->client->device()->removeTags($registrationID,$tags);
return $result;
}
// Label push
public function push($tag, $alert){
$tags = explode(",", $tag);
$response = $this->client->push()
->setPlatform(array('ios', 'android'))
->addTag($tags) // label
->setNotificationAlert($alert) // Content
->send();
// Keep a record
\DB::table('jpush_msg')->insert([
'sendno' =>$response['body']['sendno'],
'msg_id' => $response['body']['msg_id'],
'http_code' => $response['http_code'],
'date' => $response['headers']['date'],
'x-jpush-timestamp'=>$response['headers']['x-jpush-timestamp'],
'server'=>$response['headers']['server'],
'type'=>' label '
]);
return $response;
}
// Update the alias of the specified device
public function updateAlias($reg_id, $alias) {
$response = $this->client->device()->updateAlias($reg_id, $alias);
if ($response['http_code'] == 200) {
return $response;
}
return false;
}
// Alias push
// public function aliasPush($alias, $alert){
// $alias = explode(",",$alias);
// $response = $this->client->push()
// ->setPlatform(array('ios', 'android'))
// ->addAlias($alias) // Alias
// ->setNotificationAlert($alert) // Content
// ->send();
// return $response;
// }
public function aliasPush($alias, $alert,$content,$extras){
$alias = explode(",",$alias);
$response = $this->client->push()
->setPlatform(array('ios', 'android'))
->addAlias($alias) // Alias
// ->setNotificationAlert($alert) // Content
->iosNotification(['title' => $alert, 'body' => $content], [
'sound' => 'sound',
'badge' => '+1',
'extras' => $extras,
'content-available'=>true,
'mutable-content'=>true,
])
//Android
->androidNotification($alert, [
'title' => $content,
'extras' => $extras
])
// Whether the production environment
->options(array(
'apns_production' => false, // development environment Only on IOS The push of is valid
'time_to_live'=>10000
))
->send();
// Keep a record
\DB::table('jpush_msg')->insert([
'sendno' =>$response['body']['sendno'],
'msg_id' => $response['body']['msg_id'],
'http_code' => $response['http_code'],
'date' => $response['headers']['date'],
'x-jpush-timestamp'=>$response['headers']['x-jpush-timestamp'],
'server'=>$response['headers']['server'],
'type'=>' Alias '
]);
return $response;
}
public function regidPush($regid, $alert,$content,$extras){
// $alias = explode(",",$alias);
$response = $this->client->push()
->setPlatform(array('ios', 'android'))
->addRegistrationId($regid) // Alias
// ->setNotificationAlert($alert) // Content
->iosNotification(['title' => $alert, 'body' => $content], [
'sound' => 'sound',
'badge' => '+1',
'extras' => $extras,
'content-available'=>true,
'mutable-content'=>true,
])
//Android
->androidNotification($alert, [
'title' => $content,
'extras' => $extras
])
// Whether the production environment
->options(array(
'apns_production' => false, // development environment Only on IOS The push of is valid
'time_to_live'=>10000
))
->send();
// Keep a record
\DB::table('jpush_msg')->insert([
'sendno' =>$response['body']['sendno'],
'msg_id' => $response['body']['msg_id'],
'http_code' => $response['http_code'],
'date' => $response['headers']['date'],
'x-jpush-timestamp'=>$response['headers']['x-jpush-timestamp'],
'server'=>$response['headers']['server'],
'type'=>' equipment ID'
]);
return $response;
}
// notice
public function pushNotice($message){
$result = $client->push()
->setPlatform('all')
->addAllAudience()
->setNotificationAlert($message) // The information you want to push
->send();
return $result;
}
/** =================================================== Calling method =================================================== */
}
When I was doing this Aurora push, the main articles I checked were php Aurora push detailed explanation process
You can refer to many experiments , It will be done .
边栏推荐
- 计算学生成绩等级(虚函数和多态)
- Vscode 设置clang-format
- 我的IC之旅——资深芯片设计验证工程师成长——“胡”说IC工程师完美进阶
- Excel exports data to SQL and pictures to folder through macro | VBA
- OOP 向量加减(友元+拷贝构造)
- CTF_ Web: Changan cup-2021 old but a little new & asuka
- 【FLink】access closed classloader classloader.check-leaked-classloader
- DMA double buffer mode of stm32
- Deep learning - several types of learning
- Web3 DAPP user experience best practices
猜你喜欢

Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from

魔法猪系统重装大师怎么使用

great! Auto like, I use pyautogui!

At the age of 30, I began to learn programming by myself. Is it still time for me to have difficulties at home?

buuctf(re)

大话云原生数据库中的存算分离

小白一键重装官网下载使用方法

Upgrade PHP to php7 The impact of X (2), the obsolescence of mcrypt decryption

EL & JSTL (XIII)

多睡觉,能减肥,芝加哥大学最新研究:每天多睡1小时,等于少吃一根炸鸡腿...
随机推荐
In Net 6 using dotnet format formatting code
大话云原生数据库中的存算分离
Why does the SQL statement hit the index faster than it does not?
What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect
Immutable learning road -- farewell to traditional copy
MySQL concept and operation (III)
The print area becomes smaller after epplus copies the template
EL & JSTL (XIII)
JS call() and apply()
【Keil】ADuCM4050官方库的GPIO输出宏定义
jsz中的join()
olap分析引擎——Kylin4.0
两小时带你进入软件测试行业风口(附全套软件测试学习路线)
Upgrade PHP to php7 The impact of X (I). The problem of session retention. Keep login
Cookie & session & JSP (XII)
华为鸿蒙开发第四课
融合CDN,为客户打造极致服务体验!
Teach you to write non maintainable PHP code step by step
执行SQL响应比较慢,你有哪些排查思路?
Kotlin Compose 监听软键盘 点击enter提交事件