React Native Local Push Notification

Viewed 980

I was following the set-up here https://github.com/zo0r/react-native-push-notification for android, where it states that localPush and localSchedule notifications don't need firebase, however I am getting the error regarding "default firebaseapp is not initialized make sure to call firebaseapp.initializeapp(context) first"

In my app.js

import PushNotification from "react-native-push-notification";

export default class App extends Component {
 constructor(){
    PushNotification.configure({

      onRegister: function (token) {
        console.log("TOKEN:", token);
      },

      onNotification: function (notification) {
        console.log("NOTIFICATION:", notification);
      },

      // Should the initial notification be popped automatically
      // default: true
      popInitialNotification: true,

    });
 }
}

In the AndroidMainfest.xml I copied everything except the RNPushNotificationListener from the github

<uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <application ....>
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
                android:value="YOUR NOTIFICATION CHANNEL NAME"/>
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
                    android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>

        <!-- Change the value to true to enable pop-up for in foreground (remote-only, for local use ignoreInForeground) -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="false"/>
        <!-- Change the resource name to your App's accent color - or any other color you want -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color -->

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

1 Answers

Make sure you add the line

  requestPermissions: Platform.OS === 'ios',//add this line inside the .configure if u didn't install the firebase

default requestPrmission will be true but if you didn't install the react-native-firebase use above line in the PushNotification.configure

Related