Skip to content

[🐛] Bug Report Title - [Error: [messaging/unknown] no valid “aps-environment” entitlement string found for application] #8676

@namdh03

Description

@namdh03

Issue

Describe your issue here

🐛 Issue

Despite following all the setup steps provided in the official documentation, FCM works correctly on Android, but fails on iOS when trying to get the device token. The following error is thrown after calling messaging().getToken():

[Error: [messaging/unknown] no valid “aps-environment” entitlement string found for application]

Code:

async function onAppBootstrap() {
  // Request notification permissions
  const authStatus = await messaging().requestPermission({
    provisional: true,
    providesAppNotificationSettings: true,
  });
  const enabled =
    authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
    authStatus === messaging.AuthorizationStatus.PROVISIONAL;

  if (enabled) {
    try {
      // Register the device with FCM
      await messaging().registerDeviceForRemoteMessages();

      // Get the token
      const token = await messaging().getToken();

      // Save the token
      console.log('FCM Token:', token);
    } catch (error) {
      console.log('Error getting FCM token:', error);
    }
  } else {
    console.log('Failed to get notification permission');
  }
}

Log output:

(NOBRIDGE) WARN  Usage of "messaging().registerDeviceForRemoteMessages()" is not required. 
You only need to register if auto-registration is disabled in your 'firebase.json' configuration file 
via the 'messaging_ios_auto_register_for_remote_messages' property.

(NOBRIDGE) LOG  Error getting FCM token: 
[Error: [messaging/unknown] no valid “aps-environment” entitlement string found for application]

Let me know if you want help solving the issue too — I can walk you through fixing the aps-environment entitlement problem.


Project Files

Javascript

Click To Expand

package.json:

{
  "name": "projectid",
  "main": "index.ts",
  "version": "1.0.0",
  "scripts": {
    "postinstall": "npx patch-package",
    "start": "expo start --dev-client",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "android-clean": "cd android && ./gradlew clean",
    "android-debug": "cd android && ./gradlew assembleDebug",
    "android-release": "cd android && ./gradlew assembleRelease",
    "android-bundle": "cd android && ./gradlew bundleRelease",
    "android-debug-windows": "cd android && set \"NODE_ENV=production\" && gradlew.bat assembleDebug",
    "android-release-windows": "cd android && set \"NODE_ENV=production\" && gradlew.bat assembleRelease",
    "android-bundle-windows": "cd android && set \"NODE_ENV=production\" && gradlew.bat bundleRelease",
    "ios-applovin-setup": "cd ios && ruby AppLovinQualityServiceSetup-ios.rb",
    "clean-ios": "cd ios && rm -rf Pods && rm Podfile.lock && pod install --repo-update",
    "hard-clean-ios": "cd ios && rm -rf Pods && rm Podfile.lock && rm -rf ~/Library/Developer/Xcode/DerivedData/* && pod install --repo-update",
    "init-clean-ios": "cd ios && ruby AppLovinQualityServiceSetup-ios.rb && rm -rf Pods && rm Podfile.lock && rm -rf ~/Library/Developer/Xcode/DerivedData/* && pod install --repo-update",
    "test": "jest --watchAll",
    "lint": "expo lint",
    "export-apk": "java -jar bundletool.jar build-apks --bundle=app.aab --output=app.apks  --mode=universal",
    "build-android-staging": "eas build --profile staging --platform android --local",
    "build-android-prod": "eas build --profile production --platform android",
    "build-ios-staging": "eas build --profile staging --platform ios --local",
    "build-ios-prod": "eas build --platform ios --profile production",
    "build-all-staging": "eas build --profile staging --local",
    "my-ios": "expo run:ios --device='00008120-00011D423E00C01E' --port=8082",
    "my-android": "expo run:android --port=8082",
    "devices-ios": "xcrun xctrace list devices",
    "devices-andrdoid": "adb devices",
    "lucas-ios": "expo run:ios --device='00008020-000C152E2262002E'",
    "3d-ios": "expo run:ios --device='00008101-0003653226E3001E' --port=8082",
    "tho-ios": "expo run:ios --device='00008030-001829D61432402E'",
    "eas:update": "sh scripts/eas-update.sh"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "expo": {
    "doctor": {
      "reactNativeDirectoryCheck": {
        "enabled": true
      }
    },
    "autolinking": {
      "exclude": [
        "@heap/react-native-heap"
      ]
    },
    "install": {
      "exclude": [
        "react-native@~0.76.6",
        "react-native-reanimated@~3.16.1",
        "react-native-gesture-handler@~2.20.0",
        "react-native-screens@~4.4.0",
        "react-native-safe-area-context@~4.12.0",
        "react-native-webview@~13.12.5"
      ]
    }
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-native-community/netinfo": "^11.4.1",
    "@react-native-cookies/cookies": "^6.2.1",
    "@react-native-firebase/app": "^23.1.2",
    "@react-native-firebase/messaging": "^23.1.2",
    "@react-native-google-signin/google-signin": "^13.2.0",
    "@react-native-masked-view/masked-view": "0.3.2",
    "@react-native/metro-config": "^0.76.5",
    "@react-three/drei": "^9.121.4",
    "@react-three/fiber": "^8.17.14",
    "@reown/appkit-wagmi-react-native": "^1.2.2",
    "@shopify/flash-list": "^2.0.2",
    "@shopify/react-native-skia": "^2.2.3",
    "@tanstack/react-query": "^5.69.0",
    "@walletconnect/react-native-compat": "^2.19.1",
    "axios": "^1.7.9",
    "crypto-js": "^4.2.0",
    "dayjs": "^1.11.13",
    "expo": "~52.0.47",
    "expo-application": "~6.0.2",
    "expo-asset": "~11.0.5",
    "expo-av": "~15.0.2",
    "expo-blur": "~14.0.3",
    "expo-brightness": "~13.0.3",
    "expo-build-properties": "~0.13.3",
    "expo-camera": "~16.0.18",
    "expo-clipboard": "~7.0.1",
    "expo-constants": "~17.0.8",
    "expo-crypto": "~14.0.2",
    "expo-dev-client": "~5.0.20",
    "expo-device": "~7.0.3",
    "expo-document-picker": "~13.0.3",
    "expo-file-system": "~18.0.12",
    "expo-font": "~13.0.4",
    "expo-gl": "~15.0.5",
    "expo-haptics": "~14.0.1",
    "expo-image": "~2.0.7",
    "expo-image-manipulator": "~13.0.6",
    "expo-image-picker": "~16.0.6",
    "expo-keep-awake": "~14.0.3",
    "expo-linear-gradient": "~14.0.2",
    "expo-linking": "~7.0.5",
    "expo-local-authentication": "~15.0.2",
    "expo-localization": "~16.0.1",
    "expo-media-library": "~17.0.6",
    "expo-navigation-bar": "~4.0.9",
    "expo-network": "~7.0.5",
    "expo-router": "~4.0.21",
    "expo-secure-store": "~14.0.1",
    "expo-sharing": "~13.0.1",
    "expo-splash-screen": "~0.29.24",
    "expo-status-bar": "~2.0.1",
    "expo-system-ui": "~4.0.9",
    "expo-tracking-transparency": "~5.1.1",
    "expo-updates": "~0.27.4",
    "expo-video": "~2.0.6",
    "formik": "^2.4.6",
    "hermes-engine": "^0.11.0",
    "i18n-js": "^4.5.1",
    "lottie-react-native": "7.2.5",
    "onesignal-expo-plugin": "^1.1.2",
    "react": "18.3.1",
    "react-content-loader": "^7.0.2",
    "react-native": "~0.77.1",
    "react-native-animatable": "^1.4.0",
    "react-native-applovin-max": "^9.2.0",
    "react-native-compressor": "^1.10.3",
    "react-native-config": "^1.5.5",
    "react-native-confirmation-code-field": "^7.4.0",
    "react-native-date-picker": "^5.0.12",
    "react-native-device-info": "^14.0.4",
    "react-native-element-dropdown": "^2.12.4",
    "react-native-fbsdk-next": "^13.4.1",
    "react-native-gesture-handler": "~2.22.0",
    "react-native-get-random-values": "^1.11.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-keychain": "^9.2.2",
    "react-native-keys": "^0.7.12",
    "react-native-modal": "^14.0.0-rc.1",
    "react-native-onesignal": "5.2.8",
    "react-native-paper": "^5.12.5",
    "react-native-reanimated": "~3.16.7",
    "react-native-reanimated-carousel": "^4.0.0-canary.22",
    "react-native-safe-area-context": "~5.1.0",
    "react-native-screens": "~4.8.0",
    "react-native-sse": "^1.2.1",
    "react-native-svg": "15.8.0",
    "react-native-svg-transformer": "^1.5.0",
    "react-native-video": "^6.9.1",
    "react-native-webview": "~13.13.1",
    "tabler-icons-react-native": "^3.1.0",
    "three": "^0.173.0",
    "viem": "^2.23.15",
    "wagmi": "^2.14.15",
    "world-countries": "5.0.0",
    "yup": "^1.6.1",
    "zustand": "^5.0.8"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@react-native-community/cli": "^18.0.0",
    "@types/crypto-js": "^4.2.2",
    "eslint": "^8.57.0",
    "eslint-config-expo": "~8.0.1",
    "obfuscator-io-metro-plugin": "^2.1.3",
    "patch-package": "^8.0.0",
    "reactotron-react-native": "^5.1.12",
    "typescript": "^5.3.3"
  }
}

firebase.json for react-native-firebase v6:

Dont have!

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

platform :ios, '15.5'
install! 'cocoapods',
  :deterministic_uuids => false
#use_modular_headers! # Enable modular headers globally

prepare_react_native_project!

target 'ProJectID' do
  use_expo_modules!
  pod 'GoogleUtilities', :modular_headers => true
  pod 'AmazonPublisherServicesSDK'
  pod 'AppLovinMediationAmazonAdMarketplaceAdapter'
  pod 'AppLovinDSPLinkedInAdapter'
  pod 'AppLovinMediationBigoAdsAdapter'
  pod 'AppLovinMediationFyberAdapter'
  pod 'AppLovinMediationGoogleAdapter'
  pod 'AppLovinMediationInMobiAdapter'
  pod 'AppLovinMediationIronSourceAdapter'
  pod 'AppLovinMediationVungleAdapter'
  pod 'AppLovinMediationFacebookAdapter'
  pod 'AppLovinMediationMintegralAdapter'
  pod 'AppLovinMediationMolocoAdapter'
  pod 'AppLovinMediationByteDanceAdapter'
  pod 'AppLovinMediationUnityAdsAdapter'
  pod 'AppLovinMediationChartboostAdapter'
  pod "TensorFlowLiteSwift", "2.17.0"
  pod "MLImage", "1.0.0-beta6"
  pod "MLKitFaceDetection", "6.0.0"
  pod "MLKitVision", "8.0.0"

  if ENV['EXPO_USE_COMMUNITY_AUTOLINKING'] == '1'
    config_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
  else
    config_command = [
      'node',
      '--no-warnings',
      '--eval',
      'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
      'react-native-config',
      '--json',
      '--platform',
      'ios'
    ]
  end

  config = use_native_modules!(config_command)
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true
  $RNFirebaseAnalyticsWithoutAdIdSupport = true
  $RNGoogleMobileAdsAsStaticFramework = true

  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
  use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']
  inhibit_all_warnings!

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    :privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      :ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true',
    )
    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.5'
        config.build_settings['CLANG_ENABLE_MODULES'] = 'YES'
        config.build_settings['DEFINES_MODULE'] = 'YES'
      end
    end
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
    # Exclude the conflicting modulemap
  #  installer.pods_project.build_configurations.each do |config|
   #   config.build_settings['EXCLUDED_SOURCE_FILE_NAMES'] = 'ReactCommon.modulemap'
   # end
  end
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
end

AppDelegate.m:

#import "AppDelegate.h"
#import <Firebase.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>
#import <AuthenticationServices/AuthenticationServices.h>
#import <SafariServices/SafariServices.h>
#import <FBSDKCoreKit/FBSDKCoreKit-Swift.h>
// #import <RNBranch/RNBranch.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];
  
  [[FBSDKApplicationDelegate sharedInstance] application:application
                          didFinishLaunchingWithOptions:launchOptions];

  self.moduleName = @"main";
  
  // [RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
  self.initialProps = @{};

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
  if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
    return YES;
  }

  if ([RCTLinkingManager application:app openURL:url options:options]) {
    return YES;
  }

  return NO;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
  return [self bundleURL];
}

- (NSURL *)bundleURL
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@".expo/.virtual-metro-entry"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
  return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

@end


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

 info Fetching system and libraries information...
System:
  OS: macOS 15.5
  CPU: (8) arm64 Apple M1
  Memory: 1.30 GB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.4.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.5.1
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2025.07.21.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13840223
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.16
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: ^18.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.3
    wanted: ~0.77.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

info React Native v0.81.0 is now available (your project is running on v0.77.3).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.81.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.77.3&to=0.81.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • ^23.1.2???
  • Firebase module(s) you're using that has the issue:
    • Dont know
  • Are you using TypeScript?
    • Y & ^5.3.3


Image

--

Image

--

Image

--

Image

--

Image

--

Image

--

Image

--

Image

--

Image

--
File ProjectinkID.entitlements

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>aps-environment</key>
	<string>development</string>
	<key>com.apple.developer.associated-domains</key>
	<array>
		<string>applinks:prod.projectinklabs.ai</string>
		<string>applinks:projectink-id.app.link</string>
		<string>applinks:projectink-id-alternate.app.link</string>
	</array>
	<key>com.apple.security.application-groups</key>
	<array>
		<string>group.org.projectink.projectinkid.onesignal</string>
	</array>
</dict>
</plist>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions