0

I implement push notification in my application, I check it on my ipad device, in the php file, I put the device token specified:

$deviceToken = '2ca0c25ed7acea73e19c9d9193e57a12c1817ed48ddf8f44baea42e68a51563c';

until now, the notification works fine.

when I want to register devices into database, I got an the below error:

 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}

I don't understand the mentioned error, Note: that I use push notification for development and not for distribution yet.

I got the code of the registration from this link

enter image description here Thank you for you help!

CarinaM
  • 527
  • 4
  • 12
  • 27

3 Answers3

1

Have you registered your application for push notifications in the developer center? And if you have, did you re-generate your provisioning profile? You need to make sure your provisioning profile is setup for push messaging.

lxt
  • 31,146
  • 5
  • 78
  • 83
  • yes the provisioning profile is setup for push messages, the push notification is working if I put the name of device like above, but when I want to register the devices into database, i got an error – CarinaM Jul 06 '13 at 10:55
0

This error is related to certificates..Make sure you set your certificate name is correct in php file and it is present in your respective folder. Let me know if you have still error.

As a request,I am posting code of php file which is used to send notification :

<?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);
}

?>

This code of notification is of APNS library.You can see here : APNS_PHP

Ponting
  • 2,248
  • 8
  • 33
  • 61
  • I guess that my php files are the problem, do you have a link that I can download the php files and the code related to push notification? – CarinaM Jul 06 '13 at 11:12
  • ok Thank you, but my error is from registering devices into database, so the php file that inserts the devices into database, I use the php files in this link (http://iosapplove.com/archive/2012/10/apns-tutorial-how-to-send-pushnotifications-to-my-app/) – CarinaM Jul 06 '13 at 12:00
  • Please see in you database whether deviceToken is inserted in your database.If not then you have an error in didRegisterForRemoteNotificationsWithDeviceToken method while registering your device token.Or debug your code in didRegisterForRemoteNotificationsWithDeviceToken this method. You can find error there. – Ponting Jul 06 '13 at 12:06
0

As pointed out it is most likely a code-signing problem. Be sure to sign with the correct profile! Check your target and project settings if those are correct and not some kind of wildcard ID.

Also may I point out that the How-To you posted is still using UDID.

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

Push only uses the devToken and UDID use is deprecated.

A solution can be found here

Community
  • 1
  • 1
wkberg
  • 391
  • 2
  • 12
  • I use `NSString *deviceUuid = dev.uniqueDeviceIdentifier;` after i imported `#import "UIDevice+IdentifierAddition.h"` – CarinaM Jul 06 '13 at 11:28
  • Ok then that is all set. The error you got comes from being unable to register to the APNS. `didFailToRegisterForRemoteNotificationsWithError` is where your error comes from. So it isn't in your PHP files. – wkberg Jul 06 '13 at 11:37
  • So it is still a problem with your provisioning: Check if your provisioning profile has push-noti. enabled. Check if your provisioning profile has your iPad enabled. Redownload your provis profile and set the newly downloaded provis. Set the downloaded profile as the code-signing ent. in XCode. Check if your current scheme uses the "build for debug". – wkberg Jul 06 '13 at 12:31