xcode 8 push notification capabilities and entitlements file setting
Asked Answered
P

3

65

when using xcode 8 doing the push notification setting, unlike xcode 7, xcode 8 need developer turn on push notifications capabilities switch ( located at TARGETS -> AppName -> Capabilities as following pic ), push notifications capabilities

then it will generate AppName.entitlements file as following

//AppName.entitlements
<key>aps-environment</key>
<string>development</string>

but for production version App, if we change the string to

//AppName.entitlements
<key>aps-environment</key>
<string>production</string>

then the Capabilities show a warning

Capabilities warning

and it seems no matter which string value specified in aps-environment, we can still get the push device token at application:didRegisterForRemoteNotificationsWithDeviceToken:

so what is the correct setting of the push notification entitlements? thank you

Prod answered 1/9, 2016 at 8:50 Comment(3)
Any news on that? I tried the "production" option too but XCode forces change to "development" after clicking on "Fix Issue"Prussia
I did archive the app and submit to Appstore with the weird development option, and can still receive remote push notification. at the meantime, the mobileprovision file in archived app shows the production aps-environment optionProd
in my app when i'm in debug apn works well, when i release for enterprise distribution i xcode 8.1 iOS never receive any push notification...Downhaul
U
32

I was struggling with that today in Xcode 8 GM. After disabling the setting, deleting my developer portal provisioning profile and regenerating it and enabling the setting again, I was able to eliminate the warning in Xcode. Keep in mind that I didn't fiddle with the entitlements file. I left it at development environment and after archiving I got the correct aps-environment setting (production).

Seems Xcode is stilly very buggy tho even in GM

Ulphi answered 9/9, 2016 at 21:52 Comment(6)
thanks, I guess currently we have to submit Apps using this weird option, but still can get correct remote push notification. wait for Apple's fix.Prod
This is madness - our team can't get the value to change to production, despite blowing away all local provisioning profiles, manually code signing, and importing the verified production profileNewtonnext
@Newtonnext Do you try to change it in the entitlements file or you see that in organizer after archiving and trying to submit? If you see it in organizer try unchecking "Automatically manage signing" in "General" tab in your project and then choose the correct provisioning profile from the drop down.Ulphi
Thanks for responding @Shardon. We got it to work by blowing away all certificates and provisioning profiles for our specific app id on the portal (minus prod APNS certs) - we also removed local provisioning profiles, then enabled automatic code signing. After that XCode 8 setup a single provisioning profile for distribution that worked correctly. aps-environment stayed as "development", but after archiving and exporting locally for App Store, we were able to unzip and verify the included provisioning profile had aps-env correctly set to production. Confirmed working via TestFlight buildNewtonnext
Check the entitlements section after you archive - even though your file says development, it will be set to production. Yes, very confusing.Deliladelilah
As if it wasn't hard enough with needing to build it with the right certs already. Apple really screwed up on this one, I can't get it to work not in sandbox mode, and this is even building the app in release mode.Kampmeier
K
0

My problem was my pusher client was out of date and would only push successfully to debug tokens. Other issue which I am still working on a fix for is that I could only export the app via gym with legacy-api enabled, this was not setting the apns-environment to be 'production' and leaving it as 'development' in the 'embedded-mobile.provision' file. I have however been able to successfully deploy the app via the xcode organiser to work with apns(prod) now.

Kampmeier answered 15/12, 2016 at 5:1 Comment(0)
P
0

I think the better solution is open the project package and open project.pbxproj

change the CODE_SIGN_ENTITLEMENTS

CODE_SIGN_ENTITLEMENTS = "your-app/production.entitlements";
Power answered 21/12, 2016 at 10:1 Comment(1)
He already has the entitlements file linked in his project, the problem is that the Xcode UI shows a warning, and if he clicks "Fix issue", the entitlements file will contain the value "development", which is probably now what you want when you're releasing your app.Archive

© 2022 - 2024 — McMap. All rights reserved.