EasyApns — зарегистрировать устройство в базе данных — иногда происходит сбой

Я борюсь с моими push-уведомлениями в приложении ios. Многие устройства регистрируются, но некоторые нет, и я понятия не имею, почему. Я думаю, что это может быть из-за специальных символов ?!

Вот линии, где происходит волшебство.

AppDelegte.m

NSString *urlString = [NSString stringWithFormat:@"/apns.php?task=%@&appname=%@&appversion=%@&deviceuid=%@&devicetoken=%@&devicename=%@&devicemodel=%@&deviceversion=%@&pushbadge=%@&pushalert=%@&pushsound=%@&country=%@", @"register", appName,appVersion, deviceUuid, deviceToken, deviceName, deviceModel, deviceSystemVersion, pushBadge, pushAlert, pushSound, ccCodePush];

apns.php

function __construct($db, $args=NULL, $certificate=NULL, $sandboxCertificate=NULL, $logPath=NULL) {

if(!empty($certificate) && file_exists($certificate))
{
$this->certificate = $certificate;
}

if(!empty($sandboxCertificate) && file_exists($sandboxCertificate))
{
$this->sandboxCertificate = $sandboxCertificate;
}

$this->db = $db;
if($args['task']!="register")
$this->checkSetup();
$this->apnsData = array(
'production'=>array(
'certificate'=>$this->certificate,
'ssl'=>$this->ssl,
'feedback'=>$this->feedback
),
'sandbox'=>array(
'certificate'=>$this->sandboxCertificate,
'ssl'=>$this->sandboxSsl,
'feedback'=>$this->sandboxFeedback
)
);
if ($logPath !== null) {
$this->logPath = $logPath;
}
if(!empty($args)){
switch($args['task']){
case "register":
$this->_registerDevice(
$args['appname'],
$args['appversion'],
$args['deviceuid'],
$args['devicetoken'],
$args['devicename'],
$args['devicemodel'],
$args['deviceversion'],
$args['pushbadge'],
$args['pushalert'],
$args['pushsound'],
$args['country'],
isset($args['clientid'])?$args['clientid']:null
);
break;

case "fetch":
if($args['appname'])
$this->_fetchMessagesApp($args['appname']);
else
$this->_fetchMessages();
break;

case "flush":
if($args['appname'])
$this->_flushMessagesApp($args['appname']);
else
$this->_flushMessages();
break;

default:
echo "No APNS Task Provided...\n";
break;
}
}
}

А вот и вторая часть

private function _registerDevice($appname, $appversion, $deviceuid, $devicetoken, $devicename, $devicemodel, $deviceversion, $pushbadge, $pushalert, $pushsound, $country, $clientid = NULL){

if(strlen($appname)==0) $this->_triggerError('Application Name must not be blank.', E_USER_ERROR);
else if(strlen($appversion)==0) $this->_triggerError('Application Version must not be blank.', E_USER_ERROR);
else if(strlen($deviceuid)>40) $this->_triggerError('Device ID may not be more than 40 characters in length.', E_USER_ERROR);
else if(strlen($devicetoken)!=64) $this->_triggerError('Device Token must be 64 characters in length.', E_USER_ERROR);
else if(strlen($devicename)==0) $this->_triggerError('Device Name must not be blank.', E_USER_ERROR);
else if(strlen($devicemodel)==0) $this->_triggerError('Device Model must not be blank.', E_USER_ERROR);
else if(strlen($deviceversion)==0) $this->_triggerError('Device Version must not be blank.', E_USER_ERROR);
else if($pushbadge!='disabled' && $pushbadge!='enabled') $this->_triggerError('Push Badge must be either Enabled or Disabled.', E_USER_ERROR);
else if($pushalert!='disabled' && $pushalert!='enabled') $this->_triggerError('Push Alert must be either Enabled or Disabled.', E_USER_ERROR);
else if($pushsound!='disabled' && $pushsound!='enabled') $this->_triggerError('Push Sount must be either Enabled or Disabled.', E_USER_ERROR);

$appname = $this->db->prepare($appname);
$appversion = $this->db->prepare($appversion);
$deviceuid = $this->db->prepare($deviceuid);
$devicetoken = $this->db->prepare($devicetoken);
$devicename = $this->db->prepare($devicename);
$devicemodel = $this->db->prepare($devicemodel);
$deviceversion = $this->db->prepare($deviceversion);
$pushbadge = $this->db->prepare($pushbadge);
$pushalert = $this->db->prepare($pushalert);
$pushsound = $this->db->prepare($pushsound);
$clientid = $this->db->prepare($clientid);
$country = $this->db->prepare($country);

// store device for push notifications
$this->db->query("SET NAMES 'utf8';"); // force utf8 encoding if not your default
$sql = "INSERT INTO `apns_devices`
VALUES (
NULL,
'{$clientid}',
'{$appname}',
'{$appversion}',
'{$deviceuid}',
'{$devicetoken}',
'{$devicename}',
'{$devicemodel}',
'{$deviceversion}',
'{$pushbadge}',
'{$pushalert}',
'{$pushsound}',
'{$country}',
'{$this->DEVELOPMENT}',
'active',
NOW(),
NOW()
)
ON DUPLICATE KEY UPDATE
# If not using real UUID (iOS5+), uid may change on reinstall.
`deviceuid`='{$deviceuid}',
`devicetoken`='{$devicetoken}',
`devicename`='{$devicename}',
`devicemodel`='{$devicemodel}',
`deviceversion`='{$deviceversion}',
`appversion`='{$appversion}',
`pushbadge`='{$pushbadge}',
`pushalert`='{$pushalert}',
`pushsound`='{$pushsound}',
`country`='{$country}',
`status`='active',
`modified`=NOW();";
$this->db->query($sql);
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]