47

In my app, I need push notifications. I am implementing all the instructions from the push notifications docs. But I got an error from Push Notification:

Fail To Register For Remote Notifications With Error:
  Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment'
  entitlement string found for application" UserInfo=0x2340a0
  {NSLocalizedDescription=no valid 'aps-environment' entitlement string
  found for application}

What I am doing wrong?

M. A. Kishawy
  • 5,001
  • 11
  • 47
  • 72
arunkumar.p
  • 1,775
  • 4
  • 18
  • 31

15 Answers15

44

Generate a new provisioning profile, after you enable Push, and it will work!

nithinreddy
  • 6,167
  • 4
  • 38
  • 44
  • Before doing this, be sure to check if you just misconfigured the Code Signing Identity in Build Settings for debug / release. That might be the reason, and you don't have to spend more time to generate new profiles. – Almas Adilbek Mar 21 '22 at 18:56
25

I am using Xcode 6.1.1

You don't have to delete or recreate anything. You just have to make Xcode update your active certificates (including the new push notification certificate).

Simply go to Xcode > Preferences > Accounts > pick your Account > pick your Team > View Details

There click the refresh button in the lower left corner. (Also check your code signing in build settings)

enter image description here

19

I had same problem,

I solved it making sure in Built Settings, Code Signing Identity for debug is set to proper Provisioning Profile

in which you enabled push notifications.

Almas Adilbek
  • 4,371
  • 10
  • 58
  • 97
18

First, you need to make sure you use an app ID without a wildcard. Then you need to enable that app for push notifications for development.

Check this tutorial, for example.

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

uvesten
  • 3,365
  • 2
  • 27
  • 40
8

That was making me crazy. I cross-checked everything but still was getting the same error. Tried all the other solution given on the web as well. However, this did the trick for me. I create .mobileprovision file before enable APNS. This was the real mistake. Resolution of this problem :

  1. Create App ID
  2. Enable APNS
  3. Then create Provision File

If you have created provisioning profile earlier and the you have enabled APNS , you should delete provisioning file from everywhere in your system(XCode,keychain,iTuneConnect). And then create provisioning file again.

Sourabh Bhardwaj
  • 2,524
  • 1
  • 17
  • 19
  • I just did this step and it worked. It was doing my head in...Apple need to make this process more user friendly!!!! – Jeremy Aug 12 '13 at 04:56
  • Jeremy : yeah..for a new user, it is a very hectic to know how to do this in one go. Apple need to take care of it. you may accept the answer. Happy coding !! – Sourabh Bhardwaj Aug 19 '13 at 04:26
2

This just solved it for me so I will share. If you update your app id you then must delete the profile from your device, xcode, and developer.apple.com. Then create a new matching provisioning profile that is updated with the new app id settings. Its best to name it something slightly different so you know you are selecting the correct one.

Isaiah Turner
  • 2,574
  • 1
  • 22
  • 35
2

I just dealt with this issue. While there are probably a lot of things going on, here is what I learned.

When you make changes to an app ID, such as enabling push notifications, you need to create a new provisioning profile. I must have created my app ID, made a provisioning profile using it and then enabled notifications on the app ID.

Once I removed the provisioning profile from the portal, and device, I made a new one using the modified app ID. Downloaded it, tossed it on my device, wham bam thank you ma'am it worked. Hope this helps people in the future!

NicholasTGD
  • 1,256
  • 1
  • 10
  • 11
1

enter image description here

Make the Profile right.Maybe you do not set the profile.

jxdwinter
  • 2,339
  • 6
  • 36
  • 56
1

For me -> go to project settings -> app target -> Capabilities

enable Push Notifications!

Maurice Raguse
  • 4,437
  • 2
  • 29
  • 46
1

First thing you have to run applcaiton in device.

This is will happen in xcode 3.2.6. Because when you are getting everything perfect. But your application is not registering in your iphone, ipad or ipod. You need to generate a Entitlement.plst file.

  • Step: First select your project in xcode create a file. Select codesign file named it entitlement.plist(default name).
  • Put it on resource folder.
  • Right click open as xml editor.
  • Then open your provisionfile like your_apllicationName.mobileprovision (which you have created for Apns server ) in textedit mode.

Now copy some lines like the following from your provisioning profile into your entitlements file:

<key>application-identifier</key>
<string>xyz.com.company_name.app_name</string>
  <key>aps-environment</key>        
            <string>development</string>
    <key>get-task-allow</key>   
<true/>
    <key>keychain-access-groups</key>   
<array>
        <string>xyx.*</string>      
    </array>
  • Save the entitlement.plist file.
  • Run your applcation you will notify by Apns server.
Amy Worrall
  • 16,250
  • 3
  • 42
  • 65
Rajesh Maurya
  • 3,026
  • 4
  • 19
  • 37
  • This worked for me. The key was copying the whole thing, including `application-identifier`, into my entitlements. – Amy Worrall May 29 '12 at 10:04
  • Not working for me in Xcode 4.3 :( The entitlements file seems to now be named PROJECTNAME.entitlements, e.g. "Tinker6.entitlements" for my Tinker6 project. – jwl Jun 12 '12 at 15:59
  • What is error and how do you implement push notification in your application. – Rajesh Maurya Jun 20 '12 at 12:40
  • Please note that the plist file has to be named as Entitlements.plist, the answer above is short of the letter "s". :) – joe kirk Jul 02 '12 at 09:02
0

Just make sure that you are using the specific provision certificate

go to: https://developer.apple.com/ios/manage/provisioningprofiles/index.action check the status of your provision certificate, in worst cases just create new one, download it and assigne it to your project again.

Make sure which type of provision you are using, "development" or "distribution"

T.Baba
  • 649
  • 7
  • 17
0

I got same error in XCode 4.6.1, It worked for me then I delete the previous APNS profiles from the Mac and redownload the APNS provisioing profile from member center. In Build Settings at target mode, Code Signing Identity should only in Debug Mode as iphone Developer for Release put as nil or delete the developer or distribution.

Alex Zavatone
  • 4,106
  • 36
  • 54
0

I got same too. Here is how I solved.

1) Deleted provisioning profiles at ~/Library/MobileDevice/Provisioning Profiles

2) Deleted profiles from Developer Account

3) Created and installed new profiles

Note that regenarating of profiles didn't solve.

Seryozha
  • 1,649
  • 1
  • 14
  • 13
0

ok, a little embarrassing, but sometimes you spend hours on the most idiotic bugs -

so, I run the application on DEBUG mode instead of AD-HOC.

to change that, do:

scheme -> Edit Scheme...

select Run on the left, and change to Ad-Hoc dist under Build Configuration.

*of course you need to have the suitable adhoc provisioning profile under build-setting\code signing as well as the suitable APNS certificate attached to it when you create the provisioning profile.

** once you run it, it'll crush cause its not on DEBUG mode, but you can still run in from the device.

enter image description here

Aviram Netanel
  • 12,633
  • 9
  • 45
  • 69
0

If you're managing more than one apps pushes on one server then consider the following facts.

You need to process a separate private key as a p12 file to prepare pem file and this private key is generated in keychain app when you create a .certSigningRequest file. So, this CSR can be reused for same app upon expiration but a separate is needed for any other app.

zeeawan
  • 6,667
  • 2
  • 50
  • 56