Environment:
Target Platform:
iOS (iOS 9 - iPhone 8)
Development Operating System:
macOS Sierra
Build tools: Xcode
react-native: 0.50.3
"react-native-firebase": "3.1.0"
Everything works fine when the podfile is set up like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for MyApp
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'BatchedBridge', # Required For React Native 0.45.0+
'Core',
'DevSupport'
# Add any other subspecs you want to use in your project
]
end
I've followed the new instructions for installation and removed RNFirebase & React & Yoga from the podfile so it looks like this...
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for MyApp
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
...however, this causes XCode to fail with this error
/Users/ios/MyApp/AppDelegate.m:16:9: 'RNFirebaseMessaging.h' file not found
Have tried cleaning project and removing/reinstalling pods and node modules but no luck.
@joegoodall1 could you provide us with the code of your AppDelegate.m
file also please, thanks
@Salakar Thanks for the fast response.
Here's the AppDelegate.m
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "AppDelegate.h"
#import <CodePush/CodePush.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import "RNFirebaseMessaging.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#else
jsCodeLocation = [CodePush bundleURL];
#endif
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"Sitematch"
initialProperties:nil
launchOptions:launchOptions];
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];
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
return YES;
}
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[RNFirebaseMessaging didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {
[RNFirebaseMessaging didReceiveRemoteNotification:userInfo];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
[RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)())completionHandler {
[RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
@end
Hi @Salakar,
Any update on this?
@Salakar Have now got this working. Following the new install instructions (which have changed slightly from when we first installed react-native-firebase) seems to have sorted it.
@joegoodall1 how did you fix it ? i have the same issue.
Me too
@hama @brunolemos assuming you are using RN 0.50+, then please take a look at: https://github.com/invertase/react-native-firebase/issues/636
@chrisbianca mine is 0.49.5
Do you have RNFirebase listed in your Cocoapods? Or have you used react-native link
?
I used link.
Tried this comment but didn't help.
Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
project 'Projectname.xcodeproj'
target 'Projectname' do
pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'RSKImageCropper'
pod 'QBImagePickerController'
end
Podfile.lock
```PODS:
DEPENDENCIES:
SPEC CHECKSUMS:
Firebase: dbfb98ccec2dcfcd21ab9cc1b4981a3f3c8c5e26
FirebaseAnalytics: 5b02a63ead2c3f0259cfc7f15e053e440587ecf8
FirebaseAuth: cdeee95b528958dbb7dcf220ad0fb804d3a284b0
FirebaseCore: 6cf108b63997bc08c04a1ffa55a3ac0d71a59ffc
FirebaseInstanceID: 148c25c986c8699e67304b114e365713dce467f2
FirebaseMessaging: 1a11d1c0a9ed9b3f75a0685bb0ae5932e1062f5f
GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20
GTMSessionFetcher: ebaa1f79a5366922c1735f1566901f50beba23b7
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
QBImagePickerController: d54cf93db6decf26baf6ed3472f336ef35cae022
RSKImageCropper: d9a1acbc0600bf8decc8f0d21895872c99a9e4cf
PODFILE CHECKSUM: 6a2aacaf194fa5515d1ce69b74adbfd19705c44a
COCOAPODS: 1.3.1
```
@chrisbianca If I rename RNFirebaseMessaging
to RNFIRMessaging
it works!
Hi @hama,
These are the changes I made to get things working.
1) Run react-native link react-native-firebase
2) Ensure [FIRApp configure];
comes right after NSURL *jsCodeLocation;
as mentioned here (previously this was placed further down the file and was being called too late).
Hi!
I had the same problem. This is how I fixed:
I'm using react-native link not pods.
In Xcode:
1. Libraries/RNFirebase -> Build Phases:
- add to headers RNFirebaseMessaging.h
In packaging section set Public Headers Folder Path debug and release to default (/usr/local/include)
Change #import "RNFirebaseMessaging.h" to #import
Clean, Build
@projekt86 how can I add the RNFirebaseMessaging.h in the headers Libraries/RNFirebase -> Build Phases? I can't find it.
I solved this one by putting
$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/messaging
in to the Header Search paths
Just making "$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase" recursive worked for me
@JF-13 has the right answer as it will ensure each module beyond messaging will work. Thanks fam.
If you're using Pods, there's no need to import RNFirebaseMessaging.h
or add anything in AppDelegate.m
.
@calintamasyopeso that's not true. If those files are not imported you get these errors:
▸ Compiling AppDelegate.m
❌ /Users/gianfranco/temp/dec03/ios/dec03/AppDelegate.m:27:4: use of undeclared identifier 'RNFirebaseNotifications'
[RNFirebaseNotifications configure]; // for react-native-firebase w/ Notifications
^
❌ /Users/gianfranco/temp/dec03/ios/dec03/AppDelegate.m:51:5: use of undeclared identifier 'RNFirebaseNotifications'
[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
^
❌ /Users/gianfranco/temp/dec03/ios/dec03/AppDelegate.m:56:5: use of undeclared identifier 'RNFirebaseNotifications'
[[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
^
** BUILD FAILED **
new RN 0.57.7 project (with react-native init
)
headers search, select "recursive".
Most helpful comment
I solved this one by putting
$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/messaging
in to the Header Search paths