HOR-935 Retirar las notificaciones Mobile del proceso de derivación y ejecutarlas asincronamente
up observations by QA
This commit is contained in:
@@ -228,16 +228,26 @@ class NotificationDevice
|
||||
$isExistNextNotifications = $oNoti->isExistNextNotification($appFields['APP_UID'],
|
||||
$currentDelIndex);
|
||||
if (count($devicesAppleIds) > 0 && $isExistNextNotifications) {
|
||||
$oNotification = new PushMessageIOS();
|
||||
$oNotification->setSettingNotification();
|
||||
$oNotification->setDevices($devicesAppleIds);
|
||||
$response['apple'] = $oNotification->send($message, $data);
|
||||
$arrayData = array();
|
||||
$arrayData['NOT_FROM'] = $currentUserId;
|
||||
$arrayData['DEV_TYPE'] = 'apple';
|
||||
$arrayData['DEV_UID'] = serialize($devicesAppleIds);
|
||||
$arrayData['NOT_MSG'] = $message;
|
||||
$arrayData['NOT_DATA'] = serialize($data);
|
||||
$arrayData['NOT_STATUS'] = "pending";
|
||||
$notQueue = new \NotificationQueue();
|
||||
$notQueue->create($arrayData);
|
||||
}
|
||||
if (count($devicesAndroidIds) > 0 && $isExistNextNotifications) {
|
||||
$oNotification = new PushMessageAndroid();
|
||||
$oNotification->setSettingNotification();
|
||||
$oNotification->setDevices($devicesAndroidIds);
|
||||
$response['android'] = $oNotification->send($message, $data);
|
||||
$arrayData = array();
|
||||
$arrayData['NOT_FROM'] = $currentUserId;
|
||||
$arrayData['DEV_TYPE'] = 'android';
|
||||
$arrayData['DEV_UID'] = serialize($devicesAndroidIds);
|
||||
$arrayData['NOT_MSG'] = $message;
|
||||
$arrayData['NOT_DATA'] = serialize($data);
|
||||
$arrayData['NOT_STATUS'] = "pending";
|
||||
$notQueue = new \NotificationQueue();
|
||||
$notQueue->create($arrayData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,31 +15,34 @@ namespace ProcessMaker\BusinessModel\Light;
|
||||
|
||||
class PushMessageAndroid
|
||||
{
|
||||
var $url = 'https://android.googleapis.com/gcm/send';
|
||||
var $serverApiKey = "AIzaSyBO-VLXGhjf0PPlwmPFTPQEKIBfVDydLAk";
|
||||
var $devices = array();
|
||||
private $url = 'https://android.googleapis.com/gcm/send';
|
||||
private $serverApiKey = "AIzaSyBO-VLXGhjf0PPlwmPFTPQEKIBfVDydLAk";
|
||||
private $devices = array();
|
||||
private $numberDevices = 0;
|
||||
|
||||
/**
|
||||
* @param $url string the url server
|
||||
*/
|
||||
function setUrl($url){
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->$url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $apiKeyIn string the server API key
|
||||
*/
|
||||
function setKey($apiKeyIn){
|
||||
public function setKey($apiKeyIn)
|
||||
{
|
||||
$this->serverApiKey = $apiKeyIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the devices to send to
|
||||
* @param $deviceIds string or array of device tokens to send
|
||||
* @param $deviceIds string or array of device tokens to send
|
||||
*/
|
||||
function setDevices($deviceIds)
|
||||
public function setDevices($deviceIds)
|
||||
{
|
||||
if(is_array($deviceIds)){
|
||||
if (is_array($deviceIds)) {
|
||||
$this->devices = $deviceIds;
|
||||
} else {
|
||||
$this->devices = array($deviceIds);
|
||||
@@ -51,7 +54,7 @@ class PushMessageAndroid
|
||||
*/
|
||||
public function setSettingNotification()
|
||||
{
|
||||
$conf = \System::getSystemConfiguration( PATH_CONFIG . 'mobile.ini' );
|
||||
$conf = \System::getSystemConfiguration(PATH_CONFIG . 'mobile.ini');
|
||||
$this->setUrl($conf['android']['url']);
|
||||
$this->setKey($conf['android']['serverApiKey']);
|
||||
}
|
||||
@@ -62,27 +65,28 @@ class PushMessageAndroid
|
||||
* @param $data array send extra information for app
|
||||
* @return mixed
|
||||
*/
|
||||
function send($message, $data)
|
||||
public function send($message, $data)
|
||||
{
|
||||
if(!is_array($this->devices) || count($this->devices) == 0){
|
||||
$this->numberDevices = count($this->devices);
|
||||
if (!is_array($this->devices) || $this->numberDevices == 0) {
|
||||
$this->error("No devices set");
|
||||
}
|
||||
if(strlen($this->serverApiKey) < 8){
|
||||
if (strlen($this->serverApiKey) < 8) {
|
||||
$this->error("Server API Key not set");
|
||||
}
|
||||
|
||||
if (!is_null($data)) {
|
||||
$fields = array(
|
||||
'registration_ids' => $this->devices,
|
||||
'data' => array(
|
||||
'data' => array(
|
||||
"message" => $message,
|
||||
"data" => $data
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$fields = array(
|
||||
'registration_ids' => $this->devices,
|
||||
'data' => array( "message" => $message ),
|
||||
'registration_ids' => $this->devices,
|
||||
'data' => array("message" => $message),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,17 +98,17 @@ class PushMessageAndroid
|
||||
$ch = curl_init();
|
||||
|
||||
// Set the url, number of POST vars, POST data
|
||||
curl_setopt( $ch, CURLOPT_URL, $this->url );
|
||||
curl_setopt($ch, CURLOPT_URL, $this->url);
|
||||
|
||||
curl_setopt( $ch, CURLOPT_POST, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
|
||||
|
||||
// Avoids problem with https certificate
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
// Execute post
|
||||
$result = curl_exec($ch);
|
||||
@@ -114,7 +118,12 @@ class PushMessageAndroid
|
||||
return $result;
|
||||
}
|
||||
|
||||
function error($msg)
|
||||
public function getNumberDevices()
|
||||
{
|
||||
return $this->numberDevices;
|
||||
}
|
||||
|
||||
public function error($msg)
|
||||
{
|
||||
echo "Android send notification failed with error:";
|
||||
echo "\t" . $msg;
|
||||
|
||||
@@ -19,6 +19,7 @@ class PushMessageIOS
|
||||
private $pemFile = 'mobileios.pem';
|
||||
private $devices = array();
|
||||
private $response = array();
|
||||
private $numberDevices = 0;
|
||||
|
||||
/**
|
||||
* Sete server notification Ios
|
||||
@@ -44,13 +45,13 @@ class PushMessageIOS
|
||||
*/
|
||||
public function setPemFile($file)
|
||||
{
|
||||
$file = file_exists(PATH_CONFIG . $file)?$file:'mobileios.pem';
|
||||
$file = file_exists(PATH_CONFIG . $file) ? $file : 'mobileios.pem';
|
||||
$this->pemFile = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the devices token to send to
|
||||
* @param array $devicesToken of device tokens to send to
|
||||
* @param array $devicesToken of device tokens to send to
|
||||
*/
|
||||
public function setDevices($devicesToken)
|
||||
{
|
||||
@@ -81,7 +82,8 @@ class PushMessageIOS
|
||||
*/
|
||||
public function send($message, $data)
|
||||
{
|
||||
if (!is_array($this->devices) || count($this->devices) == 0) {
|
||||
$this->numberDevices = count($this->devices);
|
||||
if (!is_array($this->devices) || $this->numberDevices == 0) {
|
||||
$this->error("No devices set");
|
||||
}
|
||||
if (strlen($this->passphrase) < 8) {
|
||||
@@ -154,9 +156,14 @@ class PushMessageIOS
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
public function getNumberDevices()
|
||||
{
|
||||
return $this->numberDevices;
|
||||
}
|
||||
|
||||
public function error($msg)
|
||||
{
|
||||
echo "Android send notification failed with error:";
|
||||
echo "\t" . $msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user