registring devicetoken时推送通知ios出错

时间:2013-07-06 10:44:18

标签: iphone ios push-notification apple-push-notifications

我在我的应用程序中实现推送通知,我在我的ipad设备上检查它,在php文件中,我把设备令牌指定为:

$deviceToken = '2ca0c25ed7acea73e19c9d9193e57a12c1817ed48ddf8f44baea42e68a51563c';
直到现在,通知工作正常。

当我想将设备注册到数据库时,我得到了以下错误:

 Error in registration. Error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x1edda520 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}

我不明白上面提到的错误,注意:我使用推送通知进行开发而不是用于分发。

我从this link

获得了注册码

enter image description here 谢谢你的帮助!

3 个答案:

答案 0 :(得分:1)

您是否在开发者中心注册了推送通知申请?如果有,您是否重新生成了配置文件?您需要确保为推送消息设置配置配置文件。

答案 1 :(得分:0)

此错误与证书有关。请确保您在php文件中设置证书名称是正确的,并且它存在于您的相应文件夹中。如果您还有错误,请告诉我。

作为请求,我发布了用于发送通知的php文件代码:

<?php


// Adjust to your timezone
date_default_timezone_set('Asia/Calcutta');

// Report all PHP errors
error_reporting(-1);

// Using Autoload all classes are loaded on-demand
require_once 'ApnsPHP/Autoload.php';

// Instantiate a new ApnsPHP_Push object
$push = new ApnsPHP_Push(
ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
'ck.pem'
);

// Set the Provider Certificate passphrase
$push->setProviderCertificatePassphrase('PUT_HERE_YOUR_PASSPHRASE_WHILE_GENERATING_NOTIFICATION');

// Set the Root Certificate Autority to verify the Apple remote peer
$push->setRootCertificationAuthority('ck.pem');

// Connect to the Apple Push Notification Service
$push->connect();

// Instantiate a new Message with a single recipient
$message = new ApnsPHP_Message('PUT_HERE_DEVICE_TOKEN');

// Set a custom identifier. To get back this identifier use the getCustomIdentifier() method
// over a ApnsPHP_Message object retrieved with the getErrors() message.
$message->setCustomIdentifier("Message-Badge-3");

// Set badge icon to "1"
$message->setBadge(1);

// Set a simple welcome text
$message->setText('Hello APNs-enabled device!');

// Play the default sound
$message->setSound();

// Set a custom property
$message->setCustomProperty('acme2', array('bang', 'whiz'));

// Set another custom property
$message->setCustomProperty('acme3', array('bing', 'bong'));

// Set the expiry value to 30 seconds
$message->setExpiry(30);

// Add the message to the message queue
$push->add($message);

// Send all messages in the message queue
$push->send();

// Disconnect from the Apple Push Notification Service
$push->disconnect();

// Examine the error message container
$aErrorQueue = $push->getErrors();
if (!empty($aErrorQueue)) {
var_dump($aErrorQueue);
}

?>

此通知代码属于APNS库。您可以在此处看到:APNS_PHP

答案 2 :(得分:0)

正如所指出的那样,很可能是代码签名问题。务必使用正确的配置文件进行签名!检查目标和项目设置是否正确,而不是某种通配符ID。

我也可以指出你发布的方法仍在使用UDID。

UIDevice *dev = [UIDevice currentDevice]; NSString *deviceUuid = dev.uniqueIdentifier;

Push仅使用devToken并且不推荐使用UDID。

可以找到解决方案here