繁体   English   中英

注册设备令牌时推送通知iOS错误

[英]error with push notification ios when registring devicetoken

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

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

我从此链接获得了注册代码

在此处输入图片说明 谢谢你的帮助!

您是否已在开发人员中心注册了用于推送通知的应用程序? 如果有的话,您是否重新生成了配置文件? 您需要确保设置配置文件以进行推送消息传递。

此错误与证书有关。请确保您在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

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

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

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

推送仅使用devToken ,不赞成使用UDID。

可以在这里找到解决方案

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM