0

I fulfill all requirements for push notifications. Enabled feature in iTunes connect and then create distribution provision profile.

In Debug mode my app call: didRegisterForRemoteNotificationsWithDeviceToken. But in release build app call: didFailToRegisterForRemoteNotificationsWithError with error:

Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application"

In project i have xxx.entitlements with:

<dict>
    <key>aps-environment</key>
    <string>production</string>
</dict>

And my xxx.mobileprovision contains this strings:

<key>Entitlements</key>
<dict>
            <key>keychain-access-groups</key>
            <array>
                    <string>XXXXXXXXXX.*</string>
            </array>
            <key>get-task-allow</key>
            <false/>
            <key>application-identifier</key>
            <string>XXXXXXXXXXX.MyBundleId</string>
            <key>com.apple.developer.team-identifier</key>
            <string>XXXXXXXXXXX</string>
            <key>aps-environment</key>
            <string>production</string>
</dict>

And after exporting Ad hoc package i use command codesign -d --entitlements MyApp.app

<key>application-identifier</key>
<string>XXXXXXXXXXX.MyBundleId</string>
<key>com.apple.developer.team-identifier</key>
<string>XXXXXXXXXXX</string>
<key>get-task-allow</key>
<false/>
<key>keychain-access-groups</key>
<array>
    <string>XXXXXXXXXXX.MyBundleId</string>
</array>

where XXXXXXXXXXX it is Team ID, and everywhere is equal.

Can anyone tell me what caused this error? Thanks in advance!

Andrey M.
  • 3,021
  • 29
  • 42
  • Possibly duplicate of https://stackoverflow.com/questions/27324020/no-valid-aps-environment-entitlement-string-found-for-application-on-app-store – AshokPolu Feb 08 '19 at 09:30
  • @AshokPolu no one answer is resolve my problem. And it still not works in testflight. – Andrey M. Feb 08 '19 at 09:51
  • Do you have a production push notification certificate, if not create one and select Adhoc provisioning profile manually for 'RELEASE' mode instead of 'Automatic Code Sign'. – AshokPolu Feb 08 '19 at 09:58

1 Answers1

0

It happened because i use manual signing in project settings after enabling push capability. After that in project.pbxproj the buildSettings section for corresponding builds (release) don't contain the

CODE_SIGN_ENTITLEMENTS = MyApp/MyApp.entitlements; string.

This issue fixed by re-enabling the push capability in project settings.

Andrey M.
  • 3,021
  • 29
  • 42