Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default FirebaseApp is not initialized in this process - React Native - Local Notification

(Before you mark this question as duplicate, please read the whole question)

I am using react-native-push-notification library in my React-Native Application.

In my app I have not initialized Firebase because I do not need any remote notifications as of now. Currently I am scheduling a local notification and when the notification comes I am expecting user actions from it. Based on the button pressed I want to make appropriate API calls.

So to achieve this I used PushNotification.configure method, but it is throwing me "Default FirebaseApp is not initialized in this process. Make sure Firebase is initialised" error.

I am being forced to use Firebase, when I have absolutely no need of it.

Could someone please help me out here, I have been searching for answer from past 2 days. I am quite new to React Native and I am still learning it. Any help is appreciated.

Thanks

like image 795
Ananth Kamath Avatar asked Dec 10 '22 00:12

Ananth Kamath


1 Answers

Finally I found the solution, it was actually in the documentation itself but I somehow over looked. I will post it here because I am sure there's someone like me out there.

We are supposed to add requestPermissions: Platform.OS === 'ios', in PushNotification.configure like this:

PushNotification.configure({
    onNotification: function (notification) {
      console.log('LOCAL NOTIFICATION ==>', notification);
    },

    // This line solves the problem that I was facing.
    requestPermissions: Platform.OS === 'ios',
  });
like image 137
Ananth Kamath Avatar answered Feb 13 '23 04:02

Ananth Kamath