messaging().onNotificationOpenedApp 和 messages().getInitialNotification() 无法在 React 本机 IOS 应用程序中工作,而可以在 Android 中工作

问题描述 投票:0回答:2

如主题中提到的

messaging().onNotificationOpenedApp 和 messages().getInitialNotification() 在 React 本机 IOS 应用程序中不起作用,但在 Android 中工作

我有使用 Flipper 的依赖项,并且我知道 Firebase 需要 UseFrameworks 并且它们不能相互协作

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, min_ios_version_supported
prepare_react_native_project!


flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end

target 'myApp' do
  config = use_native_modules!
  flags = get_default_flags()
     pod 'Firebase', :modular_headers => true
     pod 'FirebaseCore', :modular_headers => true
     pod 'GoogleUtilities', :modular_headers => true
     pod 'FirebaseInstallations', :modular_headers => true
     pod 'FirebaseSessions', :modular_headers => true
     pod 'FirebaseCoreExtension', :modular_headers => true
     pod 'GoogleDataTransport', :modular_headers => true
     pod 'nanopb', :modular_headers => true
     
     $RNFirebaseAsStaticFramework = true 
     use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'HeyGroopAppTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
      end
    end
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

  pre_install do |installer|
    installer.pod_targets.each do |pod|
    if pod.name.eql?('RNCallKeep')
    def pod.build_type
    Pod::BuildType.static_library
    end
    end
    end
    end

end
 

target 'ShareMenu' do
    use_react_native!
  
    pod 'RNShareMenu', :path => '../node_modules/rn-rnf-share-menu'
    # Manually link packages here to keep your extension bundle size minimal
    use_react_native!(
       :flipper_configuration => FlipperConfiguration.enabled,
      )
  end

这就是我的 pod 文件的样子

我正在尝试获取有关开放侦听器工作的 Firebase 通知

我也尝试过删除鳍状肢依赖性并启用用户框架:静态但不幸的是同样的问题

任何投入都会受到重视

ios reactjs notifications react-native-firebase
2个回答
0
投票

该问题是由于最新版本的 Notifee React Native 造成的 @notifee/reac[电子邮件受保护] - 使用此版本,问题已得到处理

代码开始按预期工作


0
投票

我也遇到了同样的问题,我可以通过以下方式解决这个问题,

  1. 用 notifee.onForegrandEvent 替换 onNotificationOpenedApp
  2. 用 notifee.onForegrandEvent 替换 getInitialNotification

您也可以参考这篇文章。 https://atsss.medium.com/replace-all-default-fcm-notifications-with-notifee-on-ios-751cb38f6dab

编码快乐!

© www.soinside.com 2019 - 2024. All rights reserved.