no valid “aps-environment” entitlement string found for application error when implementing FCM
Asked Answered
S

1

7

When attempting to implement Firebase Cloud Messaging into my application, I am receiving the following error at runtime:

[Firebase/Messaging][I-FCM012002] Error in application:didFailToRegisterForRemoteNotificationsWithError: no valid "aps-environment" entitlement string found for application

I am receiving an FCM token, so it appears to be establishing a connection with firebase. I have read many suggestions on what the problem could be, many seem to indicate that there is a problem with my provisioning profile not allowing push notifications. I have checked these settings under "Signing & Capabilities" and it appears that the profile allows for push notifications, and has the aps-environment value in the entitlements section:

Text

Is there something else I'm missing?

Here is my development environment:

  • macOS 10.15 (Catalina)
  • Xcode 11.5
  • iPad Air 2 (test deployment device)
Simpleton answered 27/5, 2020 at 20:20 Comment(0)
S
25

I finally found the answer. Although my provisioning profile states that I have the aps-environment entitlement, and that I have Push Notification capability included, I STILL had to enable push notifications manually in the project. Additionally, the Background Modes (Remote notifications) capability needed to be added as well. These menus have changed in recent versions of xcode (for instance, the capabilities menu is now called signing and capabilities, and the add capability button is nestled up above all the settings).

In Xcode 11.5, follow these steps:

  1. Click on your workspace name
  2. Select your project in the target list
  3. Select Signing & Capabilities
  4. Click the +Capability button
  5. Add Push Notifications and Background Modes (Remote notifications) from the list.

Steps to add capabilities

Simpleton answered 29/5, 2020 at 19:0 Comment(4)
Livesaver! Thank youHypotaxis
Thanks, man save my Day, nobody mentioning thisWindowsill
Wish I found this answer a few hours ago!Deanadeanda
Important: When adding that capability make sure you add it for both Release and DebugBehavior

© 2022 - 2024 — McMap. All rights reserved.