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!