React-native-firebase: [Proposal][WIP] Messaging / FCM overhaul

Created on 8 Nov 2017  ยท  32Comments  ยท  Source: invertase/react-native-firebase

Messaging and FCM is an area that has fallen behind the rest of the library in terms of ease of use, documentation and reliability. We plan on overhauling this completely for the 3.3.0 release and rewriting from scratch to ensure that it provides the core FCM functionality in an easy to use and reliable manner.

This issue is currently a placeholder that will be updated as we agree exactly what we will support and how this will be structured in the API. It's also here to show that we're aware of the issues that have already been raised and will be addressing them as part of this work.

To help support this development and sustain the library long term, please consider backing us on Open Collective.

Android iOS Messaging

Most helpful comment

Good news, the long awaited alpha of our messaging and notifications overhaul is now available!!

Check out the release notes here: https://github.com/invertase/react-native-firebase/releases/tag/v4.0.0-alpha.1

If you have any comments and suggestions or want to report an issue, come find us on Discord

All 32 comments

FR: Notification Channels for Android O

Hi, when do you plan to release version with those fixes?

Can we split this in such a way that we could also contribute? I would be happy to help out because this is one of the core features of firebase which I assume most people use/want to use so it only makes sense that it is as stable as the underlying SDK implementation.

Hi, I have an issue with getInitialNotification, it is not working properly if MainActivity is not configure as a Launcher.

On my app, I configure a SplashActivity as a Launcher to display a SplashScreen while app loading. But when I send the notification from firebase when app exit, then tap on the notification to open the app, getInitialNotification is not return the payload that I have sent.

Step to reproduce:

  1. quit the app
  2. send a notification from firebase
  3. open app from the notification

Everything working fine if the MainActivity is the Launcher. Here is my configure:

Configure:

My AndroidManifest.xml

<activity
    android:name=".SplashActivity"
    android:label="@string/app_name"
    android:theme="@style/SplashTheme">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/SplashTheme"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:launchMode="singleTop"
    android:windowSoftInputMode="adjustResize">
</activity>

On SplashActivity, I simply start MainActivity
My SplashActivity

public class SplashActivity extends AppCompatActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    finish();
  }
}

Bug

On React Native, I call getInitialNotification(), but got a weird payload

messaging.getInitialNotification().then((payload) => {
    console.log('getInitialNotification: ', payload);
});

This is the log of payload, it's expected to have the information that I've sent, but not.

{
    opened_from_tray:true
    fcm: {
        action:null
     }
}

My Firebase Notification Payload:

{
   "to": "/topics/user-3322",
   "content_available" : false,
   "notification" : {
       "title": "this is title",
       "body": "this is message's body"
   },
   "data": {
        "type": 1,
         "extra_data":{
            "title":"this is title",
            "body":"this is message's body"
         }
   }
}

@tranquan I also encounter the same situation. Is your project use wix/react-native-navigation?

@tranquan @sapjunior I also encounter that problem and I have some workaround for it here https://github.com/invertase/react-native-firebase/issues/151#issuecomment-342807969

Hello,
Any idea of when we will be able to use this library for messaging ?
Just to know if I should wait or find another solution.
Thanks for your hard work !

@krystiansliwa wow, nice solution (y) I've just tried and it worked perfectly, thanks a lot

Thanks for the amazing works . I just wanted to ask if the issue #523 got fixed in 3.2.0 ? I see it that is closed , but in the release change log and in the commits I do not see it's mentioned as fixed .

Thanks .

@Nitroman605 We've bumped this functionality to the v3.3.0 release as it's a significant piece of work, and we wanted to be able to get Crashlytics functionality added sooner than we'd have been able to otherwise.

we can get a lot of code from here https://github.com/evollu/react-native-fcm

@sibelius I have a big concern with that idea is that That lib is not compatible with https://github.com/wix/react-native-navigation Which many of people are using it (Even their own push notification lib did not work with their navigation for some people , including me ) .

invertase firebase messaging is the only lib that worked for me and some other who are using wix navigation .

@chrisbianca @sibelius I'm happy to merge our libraries to avoid duplicated work.
However react-native-fcm has grown from simple firebase bridging library into a push notification library so I wonder if it still fits the scope of react-native-firebase.

  • it has a lot of code for local notifications which is independent of firebase cloud messaging
  • for android it uses custom_notification to get around of many limitation on android cloud messaging

@evollu maybe we can move local notification logic to another package

many things are shared between remote and local notif so I'm not sure.
but it is possible

@chrisbianca I am still experiencing all of the behavior described by @ashour in #559 even though that issue has been marked closed. I am using v3.2.2.

I still get undefined for getInitialNotification() when activating the app on iOS by clicking on a notification.

I still get caching of getInitialNotification() when starting or activating the app on Android i.e. every time I open or activate the app, getInitialNotification() is still set to the value of the last time the app was opened from a notification.

Hello, can I ask if #678 will be addressed in the v3.3.0 release? And if there is an estimate on when the release will be ready? Thanks for all your hard work on this.

@chrisbianca i am getting the message twice while its triggering once in the functions logs ,what could be the problem actually. . .

๐Ÿ‘ for https://github.com/evollu/react-native-fcm , I don't think that code for local notifications on android is issue as react-native-firebase has implemented them too. I use react-native-fcm in app with react-native-navigation and it works like a charm. @Nitroman605

For those want to track the progress of this see this branch.

@chrisbianca awesome you're tackling this. Looking forward!

oh. so the milestone for this issue is v4.0.0 now ? does i mean that it will be released later on ? I am checking this thread everyday :D

Don't worry, it is very much in progress, but as it's such a big change we're likely to run it as an alpha for a little while.

We didn't want this to stop us getting Firestore transactions out which will be the main part of v3.3.0.

ok great thx ๐Ÿ‘

Good news, the long awaited alpha of our messaging and notifications overhaul is now available!!

Check out the release notes here: https://github.com/invertase/react-native-firebase/releases/tag/v4.0.0-alpha.1

If you have any comments and suggestions or want to report an issue, come find us on Discord

Quick question as someone who is integrating with this library for the first time specifically for push notifications. If you had to integrate with this library in the next two days, would you do v4 even though it's in alpha or v3 even if though it means rewriting for v4 later?

V3 feels more alpha than V4 ๐Ÿ˜€๐Ÿ‘๐Ÿผ go for V4

On 22 Mar 2018, at 23:57, Yarian Gomez notifications@github.com wrote:

Quick question as someone who is integrating with this library for the first time specifically for push notifications. If you had to integrate with this library in the next two days, would you do v4 even though it's in alpha or v3 even if though it means rewriting for v4 later?

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

I'm glad you think that @hegelstad. I'd also go with v4 - it's far more tested than v3 despite it's alpha status, there's better documentation and if all goes well it won't be in alpha for more than a week or so...

Any volunteers who'd like to look at adding some typescript definitions for messaging and notifications?

@chrisbianca I can help with it =)

Just published a release candidate with a couple of other tasty treats (Firebase Invites, multi-database support and an overhaul of Dynamic Links): See the release notes for our latest release candidate

Going to close this now as we're close to a full release of v4 and there has been plenty of successful early testers on the alpha and RC versions.

Let's move discussions and feedback to the v4-fcm-notifications channel on discord. If you're flagging bugs for v4 please tag your github issue title with [v4] to allow us to spot them easier.

Thanks all for the feedback and thanks to all the early adopters/testers โค๏ธ

Was this page helpful?
0 / 5 - 0 ratings