136

So I have this app called Dripper that I put out about a month ago and then an update a couple days ago. The update added push notifications and a few little tweaks. I tested it with the sandbox-apn using the development profile and things worked great. Then I switched things to the production-apn and pushed it to test-flight, again things worked perfectly. Once I put update on the market and ran it I noticed I wasn’t getting any new push registrations on the server. I looked at the console logs for the device and found this:

Dec 4 17:55:15 Ina-touch-it coffco[1210] : Registering for remote notifications
Dec 4 17:55:15 Ina-touch-it SpringBoard[52] : No valid 'aps-environment' entitlement string found for application 'Dripper': (null). Notifications will not be delivered.
Dec 4 17:55:15 Ina-touch-it coffco[1210] <Warning>: Failed to register with error : Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x174270900 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}

I am a bit confused because I thought that the production-apn would function the same between ad-hoc and app store builds.

Here is my app id and its entitlements:

enter image description here

Here is the provisioning profile for the apps store:

enter image description here

mfaani
  • 33,269
  • 19
  • 164
  • 293
Jessiah
  • 1,464
  • 2
  • 9
  • 9
  • Here it is being signed and uploaded -> http://i.stack.imgur.com/AziCI.png Build settings -> http://i.stack.imgur.com/j2TFG.png – Jessiah Dec 05 '14 at 20:18

10 Answers10

339

I fix this problem by enabling push notification capability.

Click on .xcodeproj -> Capabilities -> Enable Push Notification

wei
  • 4,267
  • 2
  • 23
  • 18
  • 15
    In XCode 8 I saw an error in this section saying an entitlements file needed to be added. I clicked on this to correct it and then it worked ok. – Pellet Jun 23 '16 at 03:55
  • Only recently popped up when starting to develop in Xcode 8 and this fixed it. Thanks! – Kody R. Sep 17 '16 at 21:10
  • Was previously working on Xcode 7.3 but suddenly not registering on Xcode 8, but this solved my issue by enabling push notification capability. – Vinod Rathod Oct 12 '16 at 06:12
  • Apple decides to hide this option somewhere deep inside Xcode 8.1. Please let me know if anyone is able to find it. – Thomas Sebastian Nov 08 '16 at 07:41
  • I didn't get the "Push notification" option in the capabilities list. It was something to do with the fact that XCode was automatically generating my provisioning profile (I'm new to iOS dev so I might be wrong...). I had to sign into my developer account and manually create a provisioning profile for my app before it displayed Push Notifications in the capabilities list. Finally, enabling it fixed this issue. – Max Mumford May 01 '17 at 14:17
  • 2
    Have to add this for both Debug & Release in XCode 12. – Jabbar Mar 12 '21 at 13:39
105

I fixed this issue like this:

  • Go to Xcode "Preferences"
  • Go to "Accounts" tab
  • Select my Apple ID and click "View Details"
  • Click on the arrow on the bottom left corner to refresh
  • Click "Done"

And try again!

Source:

Cœur
  • 37,241
  • 25
  • 195
  • 267
Erwan
  • 2,512
  • 1
  • 24
  • 17
  • 6
    then you should select correct provisioning profile in Build Setting – Hashem Aboonajmi Apr 17 '15 at 07:44
  • 2
    In my case I needed to regenerate the provisioning profiles in the dev center. Then download all profiles and certificates again through Xcode > preferences > Accounts > Your Apple ID > view details button in the right corner > download all button. After that it should work again. – blackjacx Feb 25 '16 at 20:22
  • 2
    I find it sad there are so many glitches in the process of push and deployment. The only way I can tolerate any of this is to do 100% everything manually, and know what Xcode is attempting to do, and managing Keychain identities and provisioning profiles on file system and through iPhone Configuration Utility. – Tom Pace Jan 17 '17 at 19:55
60

You must have to enable Target—> capabilities—> push notification. I have faced this issue using Xcode 8. enter image description here

Ram G.
  • 3,045
  • 2
  • 25
  • 31
40

Navigation for adding push notification capabilities has changed slightly on higher versions of Xcode. Here using 12.2

Xcode 12 add notifications capabilities instructions

DariusLau
  • 1,043
  • 10
  • 9
  • Thanks, you saved my ass, this solution fixed the issue – Amjad Omari Feb 20 '22 at 09:24
  • This just resolved my issue with getting the error message. The app I'm supporting was built in Nativescript. So when I go to deploy I've been building in Navtivescript, then opening the build in XCode and following the normal steps to finish pushing up to Apple. So adding this config step will probably be something I have to do every time I push a new version, but at least it works!!! – gadildafissh Mar 19 '22 at 17:55
  • I am working on Flutter app, faced the above error & your solution worked :) You saved my day man – Rakesh Verma Mar 12 '23 at 07:44
19

Such problems are due to current Provisioning Profile does not contain APNS information, as the Provisioning Profile is created BEFORE creating the APNS certificate.

Therefore, to solve the problem, create a new Provisioning Profile & select the Provisioning Profile in Xcode. Then you are DONE.

Also, when you add push, I believe you have updated the certificates in keychain too.

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • The profile that I am using was created after I created the certificate for the production push apn. Is there something I can do to confirm that it is missing or contains the apns info? – Jessiah Dec 05 '14 at 21:12
10

Regarding Xcode 9, some of the answers are outdated or incomplete to solve this specific issue.

Here was the steps to follow for me:

1. Create the Provisioning Profile

(FCM is not a prerequisite for push notification but their guides are amazingly clear, here is the link)

To test your app while under development, you need a Provisioning Profile for development to authorize your devices to run an app that is not yet published on the App Store.

  1. Navigate to the Apple Developer Member Center and sign in.
  2. Navigate to Certificates, Identifiers and Profiles.
  3. In the drop down menu on the top left corner, select iOS, tvOS, watchOS if it's not already selected, then navigate to Provisioning Profiles > All.
  4. Click the + button to create a new Provisioning Profile.
  5. Select iOS App Development as provisioning profile type, then click Continue.
  6. In the drop down menu, select the App ID you want to use, then click Continue.
  7. Select the iOS Development certificate of the App ID you have chosen in the previous step, then click Continue.
  8. Select the iOS devices that you want to include in the Provisioning Profile, then click Continue. Make sure to select all the devices you want to use for your testing.
  9. Input a name for this provisioning profile (e.g. Firebase Sample App Development Profile), then click Generate.
  10. Click Download to save the Provisioning Profile to your Mac.
  11. Double-click the Provisioning Profile file to install it.

2. Activate Push Notification capabilities

  1. Go to project editor, from official manual enter image description here
  2. In capabilities section, Activate Push Notification enter image description here
Mike Casan Ballester
  • 1,690
  • 19
  • 33
5

I had the same problem using iOS 8.0 and above versions; I didn't get the device token and was giving error: "no valid 'aps-environment' entitlement string found for application"

I fixed it by using below steps

  • I have created new provisioning profile for the app id
  • added it into xcode
  • project Go to Xcode "Preferences"
  • Go to "Accounts" tab Select my Apple ID and click "View Details"
  • select your provisioning profile
  • Click on the arrow on the bottom left corner to refresh
  • Click "Done"

and now run the project definitely it'll work.

Matt
  • 74,352
  • 26
  • 153
  • 180
3

For some reason Wei's solution was not working for me. When clicking the Fix entitlements, Xcode generated two files and it still did not function, indeed the generated entitlements files were empty.

This was caused (apparently) by the PRODUCT_NAME of the project being rather long and including spaces and "ä" and "ö" letters. After changing it to a short version with english-only letters the fix by Wei worked correctly.

OwlOCR
  • 1,127
  • 11
  • 22
2

It took me a while to figure out what causing no valid aps-environment entitlement error. The problem was that there were two .entitlements files in XCode project. One is platform/ios//.entitlements and another one is platform/ios//Resources/.entitlements and the appropriate entitlements is present in the former file only while XCode is configured to use the latter. I updated the latter file manually and everything started to work. Another option to fix this is to change which .entitlements is used by XCode. This can be done in Build Settings --> Signing --> Code Signing Entitlements config param.

I'm not sure why there are two .entitlements files in XCode. Could it be that the cordova push plugin created the second one (i'm developing a hybrid cordova mobile app)? And what is the correct location for the .entitlements file?

Alex Ryltsov
  • 2,385
  • 17
  • 25
-2

I experienced this issue and resolved it with the first solution.

However, I have failed once because I had two apple accounts logged-in. After removed one, everything became working.