Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] FIRMessagingRemoteMessage Expected a type #4605

Closed
1 of 9 tasks
CMLCNL opened this issue Nov 24, 2020 · 8 comments
Closed
1 of 9 tasks

[🐛] FIRMessagingRemoteMessage Expected a type #4605

CMLCNL opened this issue Nov 24, 2020 · 8 comments
Labels
help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report

Comments

@CMLCNL
Copy link

CMLCNL commented Nov 24, 2020

Issue

Hello I am using "@ react-native-firebase / messaging": "^ 10.0.0" and while trying to build I get a type error of FIRMessagingRemoteMessage expected at lines 44,91,99,223,278,279 in RNFirebaseMessaging.m in ios.

node_modules/react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m:223:31: No visible @interface for 'FIRMessaging' declares the selector 'sendMessage:to:withMessageID:timeToLive:'

Project Files

Javascript

Click To Expand

package.json:

# N/A
{
  "name": "",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "a-start": "cd android && ./gradlew clean && cd .. && react-native run-android",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "pod": "cd ios && pod install && cd .."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.12.0",
    "@react-native-community/clipboard": "^1.2.3",
    "@react-native-community/datetimepicker": "^3.0.2",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/progress-bar-android": "^1.0.3",
    "@react-native-community/progress-view": "^1.1.1",
    "@react-native-community/viewpager": "^4.1.6",
    "@react-native-firebase/analytics": "^10.0.0",
    "@react-native-firebase/app": "^10.0.0",
    "@react-native-firebase/firestore": "^10.0.0",
    "@react-native-firebase/in-app-messaging": "^10.0.0",
    "@react-native-firebase/messaging": "^10.0.0",
    "@react-navigation/bottom-tabs": "^5.8.0",
    "@react-navigation/native": "^5.7.3",
    "@react-navigation/stack": "^5.9.0",
    "axios": "^0.20.0",
    "d3-array": "^2.7.1",
    "d3-scale": "^3.2.2",
    "d3-shape": "^2.0.0",
    "md5": "^2.3.0",
    "react": "16.13.1",
    "react-native": "0.63.2",
    "react-native-base64": "^0.1.0",
    "react-native-carousel-view": "^0.5.1",
    "react-native-dropdown-picker": "^3.6.8",
    "react-native-elements": "^2.3.1",
    "react-native-firebase": "^5.6.0",
    "react-native-gesture-handler": "^1.7.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.3",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-md5": "^1.0.0",
    "react-native-modal": "^11.5.6",
    "react-native-pdf": "^6.2.0",
    "react-native-reanimated": "^1.13.0",
    "react-native-restart": "0.0.17",
    "react-native-safe-area-context": "^3.1.7",
    "react-native-screens": "^2.10.1",
    "react-native-share": "^3.7.1",
    "react-native-svg": "^12.1.0",
    "react-native-svg-charts": "^5.4.0",
    "react-native-swipeable": "^0.6.0",
    "react-native-tab-view": "^2.15.2",
    "react-native-vector-icons": "^7.0.0",
    "react-native-webview": "^10.8.2",
    "react-redux": "^7.2.1",
    "redux": "^4.0.5",
    "rn-fetch-blob": "^0.12.0",
    "utf8": "^3.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/runtime": "^7.8.4",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^25.1.0",
    "eslint": "^6.5.1",
    "jest": "^25.1.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'entegra' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])
  target 'entegraTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'entegra-tvOS' do
  # Pods for entegra-tvOS

  target 'entegra-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

AppDelegate.m:

// N/A
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@import Firebase;

#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>

static void InitializeFlipper(UIApplication *application) {
  FlipperClient *client = [FlipperClient sharedClient];
  SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
  [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
  [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  [client addPlugin:[FlipperKitReactPlugin new]];
  [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  [client start];
}
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef FB_SONARKIT_ENABLED
  InitializeFlipper(application);
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"entegra"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  [FIRApp configure];
  return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end


RNFirebaseMessaging.m :

RCT_EXPORT_METHOD(sendMessage:(NSDictionary *) message
resolve:(RCTPromiseResolveBlock) resolve
reject:(RCTPromiseRejectBlock) reject) {
if (!message[@"to"]) {
reject(@"messaging/invalid-message", @"The supplied message is missing a 'to' field", nil);
}
NSString *to = message[@"to"];
NSString *messageId = message[@"messageId"];
NSNumber *ttl = message[@"ttl"];
NSDictionary *data = message[@"data"];

[[FIRMessaging messaging] sendMessage:data to:to withMessageID:messageId timeToLive:[ttl intValue]];

// TODO: Listen for send success / errors
resolve(nil);

}

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:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • [ x] 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:
    • e.g. 10.0.0
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y/N & VERSION


@CMLCNL CMLCNL added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels Nov 24, 2020
@mikehardy
Copy link
Collaborator

Hi there!
This demonstrator shows it works, if you can reproduce after trying this, we can reopen: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

@mikehardy
Copy link
Collaborator

(my guess is that you have crossed up versions, as that type was removed in #4471)

@CMLCNL
Copy link
Author

CMLCNL commented Nov 24, 2020

@mikehardy
"@react-native-firebase/app": "^10.0.0",
"@react-native-firebase/messaging": "^10.0.0",

I tried but it didn't work.

@mikehardy
Copy link
Collaborator

This demonstrator shows it works, if you can reproduce after trying this, we can reopen: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

@CMLCNL
Copy link
Author

CMLCNL commented Nov 24, 2020

// Establish Firebase managed data channel
[FIRMessaging messaging].shouldEstablishDirectChannel = YES;

Property 'shouldEstablishDirectChannel' not found on object of type 'FIRMessaging *'

I get this error. @mikehardy

@mikehardy
Copy link
Collaborator

I feel as though you are avoiding reading release notes? https://github.com/invertase/react-native-firebase/blob/master/packages/messaging/CHANGELOG.md#breaking-changes-1

Perhaps npx react-native-clean-project will fix you up. Something is wrong in your local project

@CMLCNL
Copy link
Author

CMLCNL commented Nov 24, 2020

my project was working. When I switched to version 10 I started getting these errors.
"@react-native-firebase/analytics": "^10.0.0",
"@react-native-firebase/app": "^10.0.0",
"@react-native-firebase/firestore": "^10.0.0",
"@react-native-firebase/in-app-messaging": "^10.0.0",
"@react-native-firebase/messaging": "^10.0.0",

react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m

I get an error saying expected a type.

Example :

// Listen for data messages in the foreground

  • (void)applicationReceivedRemoteMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage {
    NSDictionary *message = [self parseFIRMessagingRemoteMessage:remoteMessage];
    [self sendJSEvent:self name:MESSAGING_MESSAGE_RECEIVED body:message];
    }

FIRMessagingRemoteMessage expected a type.

@mikehardy
Copy link
Collaborator

That file does not exist react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m

https://github.com/invertase/react-native-firebase/tree/master/packages/messaging/ios/RNFBMessaging

Something is wrong with your local project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report
Projects
None yet
Development

No branches or pull requests

2 participants