3

We are working on an IOS application, we want to implement PUSH NOTIFICATION, I have gone through apple documentation, and asked my Team agent to enable the Push Notification in iOS dev center, they did it seems, its enabled now. I have registered in my application for Push notification like below...

     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

When I ran the application, didFailToRegisterForRemoteNotificationsWithError got called, I was not able to predict the problem, Is there anything else I can do with certification.

thanks...

Newbee
  • 3,231
  • 7
  • 42
  • 74
  • Did you execute the code on simulator or device? Push notifications will not work on simulator. – Vidya Murthy Mar 15 '13 at 06:52
  • @VidyaMurthy Device only iPod touch. – Newbee Mar 15 '13 at 06:54
  • You mentioned `-[UIApplication application:didFailToRegisterForRemoteNotificationsWithError:]` is getting called. What does the `NSError` which is passed to that callback say the problem is? You should be able to print it using `NSLog(@"Error: %@", error);` – Stuart M Mar 15 '13 at 07:03
  • @StuartM I got this : Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x59c260 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application} – Newbee Mar 15 '13 at 07:07

3 Answers3

15

For push Notification

What you need to do is, First open the provisioning portal and then go to App IDs section.

Find your app and then there are two options for configuring the Push Notification, one for Development and another for production.

If your app is under testing and development, use development and configure that and in return you will get the certificate. which will be placed on the server who will send push notifications.

Next, then you need to regenerate the provisioning profiles,

Go to the provisioning profiles and modify them and then re-download. You will get Push Notification Enabled Provisioning profiles.

Don't forget to implement this method in the AppDelegate of your project (APP):

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{

}

Build your project with the new profile and you are good to go.

For more help check this tutorial.

Even after you've enabled your app id for push, it might take a couple of hours for it to work.

Rajan Balana
  • 3,775
  • 25
  • 42
  • As a team member I am not allowed to configure I guess, My team agent should do that right. I reported earlier, they configure it and its enabled now... I am not sure they used that certificate in server, I have downloaded it in my side and I am doing this. without server changes it won't get success? – Newbee Mar 15 '13 at 06:59
  • @Newbee It will work, you will get device token in return, if you build your app with the correct Provisioning profile. See the edit – Rajan Balana Mar 15 '13 at 07:00
  • How can I come to know my provision profile is updated for Push Any way? – Newbee Mar 15 '13 at 07:04
  • @Newbee if provisioning profile is not updated (not the push notification enabled one) then you will get this error : no valid 'aps-environment' entitlement string found for application" UserInfo=0x2340a0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application – Rajan Balana Mar 15 '13 at 07:07
  • Ya I got that one. But I have downloaded now the provisioning profile. And added in Xcode. In portal its enabled also. Might be a problem in configuring provision. – Newbee Mar 15 '13 at 07:08
3

If you are getting this message:

no valid 'aps-environment' entitlement string found for application

in the NSError that is passed to -[UIApplication application:didFailToRegisterForRemoteNotificationsWithError:], you may need to check that you're using the correct provisioning profile, and that it is the one that is Push Notification-enabled. See these posts for some pointers:

Community
  • 1
  • 1
Stuart M
  • 11,458
  • 6
  • 45
  • 59
1

Just go to your applications. Then configure it for "Push Notification".

enter image description here

Configure & Enable it for Development Push SSL Certificate.

Then download latest certificate for application.

Thanks.

Manann Sseth
  • 2,745
  • 2
  • 30
  • 50