2013-07-06 75 views
0

我實現我的應用程序推送通知,我檢查我的iPad設備上,在PHP文件,我把指定的設備令牌:誤差推送通知IOS時,在註冊devicetoken

$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 謝謝您的幫助!

回答

1

您是否在開發人員中心註冊了推送通知應用程序?如果你有,你是否重新生成配置文件?您需要確保您的供應配置文件設置爲推送消息。

+0

是供應曲線是設置推送消息,推送通知是工作,如果我把設備的名稱,如上述,但是當我想註冊的設備到數據庫中,我得到了一個錯誤 – CarinaM

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 library.You的可以在這裏看到:APNS_PHP

+0

我想我的PHP文件是問題,你有一個鏈接,我可以下載PHP文件和推送通知相關的代碼? – CarinaM

+0

我編輯了我的答案。請看那裏。 – Ponting

+0

好的謝謝,但我的錯誤是從設備註冊到數據庫,所以PHP文件,插入設備到數據庫,我使用PHP文件在這個鏈接(http://iosapplove.com/archive/2012/10/apns -tutorialnotifications-to-my-app /) – CarinaM

0

尖的這很可能是一個代碼簽名問題。一定要簽署正確的配置文件!檢查你的目標和項目設置,如果這些是正確的,而不是某種通配符ID。

我也可以指出,您發佈的操作方法仍然使用UDID。

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

推僅使用devToken和UDID的使用被廢棄。

一個辦法可以解決here

+0

我使用'NSString * deviceUuid = dev.uniqueDeviceIdentifier;'在我導入了'#import'UIDevice + IdentifierAddition。h「' – CarinaM

+0

好了,那就是所有的設置了,你得到的錯誤來自於無法註冊到APNS,'didFailToRegisterForRemoteNotificationsWithError'是你的錯誤來自的地方,所以它不在你的PHP文件中 – wkberg

+0

所以它是什麼錯誤來自於此方法 – CarinaM