4

I am using react-native-fcm first time and according to documentation i have done all the linking stuff and using cloud messaging tab in firebase console for sending notification.

After sending notification status comes as complete and for IOS its working fine(getting notification) but android nothing is coming up. I am using mi device for testing that is having android N This is my build.gradle settings.

    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "XXXXXX"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 39
        versionName "1.91"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

Please help me out i am searching from a long but unable to find solution. Advance Thanks!!!

Edit after some experiments on 8/6/2018

i've tried so many things nothing workout then i have created an new project firebase and react native as well. and everything is working on that (getting notification) then i start checking my old project files and new files and after so many experiments i found out the issue is with tools:node="replace" i have added this because of react-native-facebook-login (some solutions on google some error i got).

now please help me with this android code how to write it because my assumption is that tools:node="replace" is overriding my fcm code with Facebook login one according to this reference. i cant remove tools:node="replace" its crashing app just after clicking app icon.

<application
      tools:node="replace" <-- this is culprit
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      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>
      <!-- <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/icon"/> -->
      <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:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:screenOrientation="portrait" android:name="com.facebook.react.devsupport.DevSettingsActivity" />

      <!--add FacebookActivity-->
      <activity
        tools:replace="android:theme"
        android:screenOrientation="portrait"
        android:name="com.facebook.FacebookActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

      <!--add CustomTabActivity-->
      <activity
        android:screenOrientation="portrait"
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
      </activity>

      <!--reference your fb_app_id-->
      <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/fb_app_id"/>
      <meta-data android:name="com.bugsnag.android.API_KEY"
        android:value="xxxxxxxxxxxxxx"/>
    </application>
Shubhanu Sharma
  • 1,957
  • 12
  • 30

1 Answers1

1

Even if you should post all your content of android/build.gradle and even the android/app/build.gradle, I want to help you saying that you should use react-native-firebase because react-native-fcm will no longer receive new features.

react-native-firebase has introduced new firebase messaging and remote/local notification features. It has good integration with other firebase features. I would recommend new comers to check that.

Note that there are some advanced features still in progress

handle iOS remote notification when app is not running custom iOS notification actions To existing react-native-fcm users react-native-firebase now can do what react-native-fcm can so it is a waste of effort to build the same thing in parallel.

Since I'm getting busier these days and start feeling challenging to maintain this repo every day while react-native-firebase has a larger team/company backing it, existing users may consider migrating to react-native-firebase.

I've created an example project using react-native-firebase as a migration reference

react-native-fcm will still take PRs and bug fixes, but possibly no new feature developement any more.

Paolo Dell'Aguzzo
  • 1,431
  • 11
  • 14
  • 1
    Yes i know that and i tries integrating that today that also wont workout. then i cloned react-native-firebase starter kit and linked that with my firebase (created new android app with app id and added json to the android>app folder) that also is not woking for me idk what i am missing. check this: https://stackoverflow.com/questions/50742795/push-notification-is-not-popping-up-react-native-firebase-with-starter-kit – Shubhanu Sharma Jun 07 '18 at 16:44
  • the problem of react-native-firebase is that it dependencies is incompatible with the other libs like react-native-map – Mr.Ghamkhar Aug 19 '18 at 06:02