Getting an error from push notification
Asked Answered
J

15

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?

Johnsen answered 28/3, 2011 at 10:55 Comment(2)
read here, it might help you urbanairship.com/docsRick
Please mark my answer as the right answer, as it would help other new users too!Dorton
D
44

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

Dorton answered 10/7, 2012 at 19:25 Comment(1)
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.Mihe
D
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

Dunnock answered 11/12, 2014 at 19:48 Comment(1)
Unfortunately in Xcode 7 this button is swapped for "Download All"Mandolin
M
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.

Mihe answered 27/2, 2013 at 17:53 Comment(0)
T
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.

Terceira answered 28/3, 2011 at 11:3 Comment(0)
A
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.

Achromatism answered 8/11, 2012 at 11:2 Comment(2)
I just did this step and it worked. It was doing my head in...Apple need to make this process more user friendly!!!!Spiteful
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 !!Achromatism
T
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!

Tocantins answered 5/1, 2012 at 19:10 Comment(0)
A
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.

Almira answered 23/10, 2012 at 1:52 Comment(0)
B
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.
Band answered 30/3, 2012 at 10:59 Comment(4)
This worked for me. The key was copying the whole thing, including application-identifier, into my entitlements.Corn
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.Perse
What is error and how do you implement push notification in your application.Band
Please note that the plist file has to be named as Entitlements.plist, the answer above is short of the letter "s". :)Tuinal
R
1

enter image description here

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

Reword answered 11/6, 2014 at 10:54 Comment(0)
B
1

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

enable Push Notifications!

Bobble answered 4/1, 2017 at 12:54 Comment(0)
D
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"

Darendaresay answered 15/12, 2012 at 8:49 Comment(0)
G
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.

Groundage answered 26/9, 2013 at 7:22 Comment(0)
S
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.

Salesroom answered 12/2, 2015 at 7:47 Comment(0)
D
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

Disapprobation answered 21/7, 2015 at 11:54 Comment(0)
D
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.

Desmund answered 31/10, 2015 at 6:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.