evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 679 forks source link

Local notification is not called in Android #1094

Open elad823 opened 5 years ago

elad823 commented 5 years ago

Before openning an issue

  1. Reproduce it with the example project in this repo.
  2. If you can't receive iOS notification, make sure you can receive notification using quickstart-ios project provided by Firebase team

When openning an issue, please include following information for better support

  1. What version of RN and react-native-fcm are you running?
  2. What device are you using? (e.g iOS9 emulator, Android 6 device)?
  3. Is your app running in foreground, background or not running?
elad823 commented 5 years ago

When I call presentLocalNotification in Android, No notfication is displayed, and FCM.on(FCMEvent.Notification , receivedNotification) is not called either. Not in background and not in Foregroud.

(When I sending remote notification, notfication is displayed but FCM.on(FCMEvent.Notification , receivedNotification) is not called)

FCM.presentLocalNotification({
       title: "Test Notification",
       body: "Test Notification Body",
       priority: "high",
       show_in_foreground: true})

AndroidMainifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.travelmaker"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <uses-sdk android:targetSdkVersion="22" />

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme">
      <receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
      <receiver android:enabled="true" android:exported="true"  android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
          <intent-filter>
              <action android:name="android.intent.action.BOOT_COMPLETED"/>
              <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
              <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
              <category android:name="android.intent.category.DEFAULT" />
          </intent-filter>
      </receiver>

      <!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
           See README(https://goo.gl/l4GJaQ) for more.
      <meta-data
          android:name="com.google.firebase.messaging.default_notification_icon"
          android:resource="@drawable/ic_stat_ic_notification" />-->

      <!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
           notification message. See README(https://goo.gl/6BKBk7) for more.
      <meta-data
          android:name="com.google.firebase.messaging.default_notification_color"
          android:resource="@color/colorAccent" />-->

        <!--If you prefer to create and use your own default channel,
            set default_notification_channel_id to the ID of your notification channel object as shown;
            FCM will use this value whenever incoming messages do not explicitly set a notification channel.

        <meta-data
              android:name="com.google.firebase.messaging.default_notification_channel_id"
              android:value="my_default_channel"/>
         !-->

           <service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
             <intent-filter>
               <action android:name="com.google.firebase.MESSAGING_EVENT"/>
             </intent-filter>
           </service>

           <service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
            <intent-filter>
               <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
             </intent-filter>
           </service>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:launchMode="singleTop"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    </application>

</manifest>
Udbhav12 commented 5 years ago

@elad823 Did you manage to solve this problem ?