0

我在我的应用程序中实现推送通知,我在我的 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}

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

我从这个链接得到了注册码

在此处输入图像描述 谢谢你的帮助!

4

3 回答 3

1

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

于 2013-07-06T10:47:04.330 回答
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

于 2013-07-06T10:56:22.460 回答
0

正如所指出的,这很可能是代码签名问题。请务必使用正确的个人资料签名!检查您的目标和项目设置是否正确,而不是某种通配符 ID。

我还可以指出,您发布的操作方法仍在使用 UDID。

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

Push 仅使用devTokenUDID 使用已弃用。

可以在这里找到解决方案

于 2013-07-06T11:10:15.837 回答