I have implemented push notification for android and it work 100% correctly but when I open the same app to test push notification for IOS it fails as it requires for a config file here is my config file code:
import { firebase } from '@react-native-firebase/messaging';
const reactNativeFirebaseConfig = {
apiKey: "my apiKey",
...
...
measurementId: "my measurementID XYZ"
};
firebase.initializeApp(reactNativeFirebaseConfig);
now the issue is even after adding this to my project gives an error: No Firebase App ‘[DEFAULT]’ has been created – call firebase.initializeApp()
Note: I am using ‘@react-native-firebase/app’; and ‘@react-native-firebase/messaging’ for push notification which is working for Android. anyone knows what is wrong on my code side or where should I use that config file as I saved this file as FirebaseConfig.js.
2
Answers
To setup Firebase on iOS, you need to do a few extra steps.
Open Firebase, and create a new iOS app.
Fill in the bundle identifier and give it a nickname of your choice.
Next download the google services file and open xCode.
Drag the Google Services file into the file tree yourApp/yourApp, next to your AppDelegate.m file.
Open AppDelegate.m and add
to the top.
Next, at around line 58 there should be a return YES.
Add this above the return
Lastly, after the return and close bracket, add this code.
All together it should look similar to this.
After you’ve done that, you should be all set to send your first message to your app.
Bare in mind that Firebase isn’t very quick to send messages, it can take a few minutes to come through.
Side-note you cant sent notifications to a iOS simulator, only a real device. You also need to add Notification permission to the app in your Apple developer account, and in xCode.
If you need help setting this up, let me know and we can Skype.
You need to add a check in the following file’s method didFinishLuanchWithOptions ios/{AppName}/AppDelegate.m