invertase / react-native-firebase

πŸ”₯ A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

[πŸ›] FIRMessagingRemoteMessage Expected a type #4605

Closed CMLCNL closed 3 years ago

CMLCNL commented 3 years ago

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`: ```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: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # 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`: ```objc // N/A #import "AppDelegate.h" #import #import #import @import Firebase; #ifdef FB_SONARKIT_ENABLED #import #import #import #import #import #import 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`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


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`


mikehardy commented 3 years ago

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 commented 3 years ago

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

CMLCNL commented 3 years ago

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

I tried but it didn't work.

mikehardy commented 3 years ago

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 commented 3 years ago
// Establish Firebase managed data channel
[FIRMessaging messaging].shouldEstablishDirectChannel = YES;

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

I get this error. @mikehardy

mikehardy commented 3 years ago

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 commented 3 years ago

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

FIRMessagingRemoteMessage expected a type.

mikehardy commented 3 years ago

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.