I followed Evan Bacon video tutorial on how to eject an app and use firebase cloud messaging for notifications.
Using a clean project I arrive up to this point:
First, my AppDelegate.m looks like this:
// Copyright 2015-present 650 Industries. All rights reserved.
#import "AppDelegate.h"
#import <FirebaseCore/FIROptions.h>
#import <FirebaseCore/FIRApp.h>
@implementation AppDelegate
// Put your app delegate methods here. Remember to also call methods from EXStandaloneAppDelegate superclass
// in order to keep Expo working. See example below.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@endesia
Then as soon I add import 'expo-firebase-auth'; to App.js the app fails to build:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import firebase from 'expo-firebase-app';
import 'expo-firebase-auth';
export default class App extends React.Component {
componentDidMount() {
console.log(firebase.auth());
}
I get several errors
[16:24:17] Unable to resolve "expo-firebase-remote-config" from "node_modules/expo-firebase-app/src/utils/getModuleInstance.js"
and the project can’t start.
If I install the missing module yarn add expo-firebase-remote-config
The next error is then
Unable to resolve "expo-firebase-crashlytics" from "node_modules/expo-firebase-app/src/utils/getModuleInstance.js"
I had the same problem going through the tutorial today. I don’t know what EXPO or Evan will create for a long term fix, but in the short term, here is what you can do to get your app building without that error.
Go to your node_modules/expo-firebase-app/src/utils/getModuleInstance.js file and comment out all of the Expo-Firebase modules you are not using. Don’t comment get utils. That’s it.
Now restart your server with yarn start or expo start or npm start first and then Run your project from X code second. Your project should now build. Let me know if that works for you.
However the data payload after a POST is always empty.
this.messageListener = firebase.messaging().onMessage(message => {
// Process your message as required
console.log(message.data.status);
console.log(JSON.stringify(message));
alert('coucou');
});
I am encountering this same problem … seems that this makes it impossible to run the project without crashlytics … this wouldn’t be a problem for me if i was using crashlytics, but i found that i lose the JS stack trace in the crash report which makes it useless … at the risk of hijacking this thread, does anyone have crashlytics working with JS stack traces?