|
@@ -30,14 +30,14 @@ class PushService
|
|
*/
|
|
*/
|
|
public static function setUserRegId($uid, string $regId, string $provider, string $package): bool
|
|
public static function setUserRegId($uid, string $regId, string $provider, string $package): bool
|
|
{
|
|
{
|
|
- myLog('push')->info('setUserRegId', compact('uid', 'regId', 'provider', 'package'));
|
|
|
|
-
|
|
|
|
// push服务商(转小写)
|
|
// push服务商(转小写)
|
|
$provider = strtolower($provider);
|
|
$provider = strtolower($provider);
|
|
- if (empty($uid) || empty($regId) || empty($package) || empty($provider)) {
|
|
|
|
|
|
+ if (empty($uid) || empty($regId) || empty($package) || empty($provider) || $package !== 'com.app.kyy.xnyd') {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ myLog('push')->info('setUserRegId', compact('uid', 'regId', 'provider', 'package'));
|
|
|
|
+
|
|
// 获取缓存
|
|
// 获取缓存
|
|
$userCacheRegId = PushCache::getUserPushRegId($uid);
|
|
$userCacheRegId = PushCache::getUserPushRegId($uid);
|
|
if ($regId === $userCacheRegId) {
|
|
if ($regId === $userCacheRegId) {
|
|
@@ -288,9 +288,16 @@ class PushService
|
|
$client = new HwPushCommon($appId, $appSecret);
|
|
$client = new HwPushCommon($appId, $appSecret);
|
|
|
|
|
|
// 循环推送
|
|
// 循环推送
|
|
|
|
+ $i = 0;
|
|
foreach ($regIdArr as $regIdList) {
|
|
foreach ($regIdArr as $regIdList) {
|
|
$client->setToken($regIdList);
|
|
$client->setToken($regIdList);
|
|
$result = $client->sendPushMessage($title, $content, $url);
|
|
$result = $client->sendPushMessage($title, $content, $url);
|
|
|
|
+
|
|
|
|
+ // 一般的应用默认消息流控是针对单个应用3000QPS(每秒不能超过3000个token数)
|
|
|
|
+ $i++;
|
|
|
|
+ if ($i % 3 === 0) {
|
|
|
|
+ sleep(1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
// 小米
|
|
// 小米
|
|
@@ -299,9 +306,16 @@ class PushService
|
|
$client = new MiPushCommon($package, $appSecret);
|
|
$client = new MiPushCommon($package, $appSecret);
|
|
|
|
|
|
// 循环推送
|
|
// 循环推送
|
|
|
|
+ $i = 0;
|
|
foreach ($regIdArr as $regIdList) {
|
|
foreach ($regIdArr as $regIdList) {
|
|
$client->setRegArr($regIdList);
|
|
$client->setRegArr($regIdList);
|
|
$result = $client->sendMessage($title, $content, $url);
|
|
$result = $client->sendMessage($title, $content, $url);
|
|
|
|
+
|
|
|
|
+ // 一般的应用默认消息流控是针对单个应用3000QPS(每秒不能超过3000个token数)
|
|
|
|
+ $i++;
|
|
|
|
+ if ($i % 3 === 0) {
|
|
|
|
+ sleep(1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
// OPPO
|
|
// OPPO
|
|
@@ -311,9 +325,15 @@ class PushService
|
|
$messageId = $client->getMessageId($title, $content, $url);
|
|
$messageId = $client->getMessageId($title, $content, $url);
|
|
|
|
|
|
// 循环推送
|
|
// 循环推送
|
|
|
|
+ $i = 0;
|
|
foreach ($regIdArr as $regIdList) {
|
|
foreach ($regIdArr as $regIdList) {
|
|
$client->setRegArr($regIdList);
|
|
$client->setRegArr($regIdList);
|
|
$result = $client->broadCastRegIds($messageId);
|
|
$result = $client->broadCastRegIds($messageId);
|
|
|
|
+ // 一般的应用默认消息流控是针对单个应用3000QPS(每秒不能超过3000个token数)
|
|
|
|
+ $i++;
|
|
|
|
+ if ($i % 3 === 0) {
|
|
|
|
+ sleep(1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|