Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not receiving message when app is close on Android #2074

Closed
chevulkar opened this issue Apr 22, 2019 · 10 comments
Closed

Not receiving message when app is close on Android #2074

chevulkar opened this issue Apr 22, 2019 · 10 comments
Labels
plugin: messaging FCM only - ( messaging() ) - do not use for Notifications Type: Stale Issue has become stale - automatically added by Stale bot

Comments

@chevulkar
Copy link

I followed the steps mentioned here.

Now, I'm receiving messages when app is in foreground via firebase.messaging().onMessage and in the background via a headless task I defined according to the same guide, but I don't receive messages when the app is closed

I am using one plus 6, where I even disabled the Battery optimise option for my phone, tried installing a signing build but none of it is working.

import firebase from 'react-native-firebase';
// Optional flow type
import type { RemoteMessage } from 'react-native-firebase';

export default async (message: RemoteMessage) => {

    const channel = new firebase.notifications.Android.Channel('channel-id', 'channel-Name', firebase.notifications.Android.Importance.Max)
    .setDescription('Description');
    firebase.notifications().android.createChannel(channel);

    const localNotification = new firebase.notifications.Notification()
    .setNotificationId(message.messageId)
    .setTitle("Title")
    .setSubtitle('Test')
    .setBody("Body")
    .setData(message.data)
    .android.setChannelId('channel-id')
    .android.setAutoCancel(false)
    .android.setPriority(firebase.notifications.Android.Priority.High);

  firebase.notifications().displayNotification(localNotification);

    return Promise.resolve();
}

Even added this on AndroidManifest.xml

<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />

Am I missing anything on native side ?

@mikehardy
Copy link
Collaborator

It is my understanding for Android development that if your app is actually closed/killed, it is not running at all, so it may not receive messages period - it can't do anything.

The only way to then have it come alive again is to register for some Intent that the system will send. I am naive with regard to firebase messaging in particular but I would look in the docs for some form of BroadcastReceiver (to catch an Intent) that you are supposed to put in your AndroidManifest, hooked to Google Play services for messaging somehow. If you are able to look in Android Studio at the "merged" AndroidManifest and you see no receivers (either from your project or merged in from a library) then there's no mechanism to start the app in response to an Intent so it isn't able to do anything

@chevulkar
Copy link
Author

Is there any working code that I can refer. I have searched across the internet tied different codes but nothing seems to work :(

@mikehardy
Copy link
Collaborator

Looks like it is almost impossible to do it reliably

firebase/quickstart-android#41 (comment)

@quarryman
Copy link

quarryman commented Apr 24, 2019

@chevulkar

I followed the steps mentioned here.

Can you provide a link to steps you followed?

@Ehesp Ehesp added the plugin: messaging FCM only - ( messaging() ) - do not use for Notifications label Apr 24, 2019
@ricardoroth
Copy link

Looks like this is a very weird intended behavior:

firebase/quickstart-android#368 (comment)

@stale
Copy link

stale bot commented Jun 3, 2019

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Jun 3, 2019
@yudiz-vipul
Copy link

This issue is not fixed yet, I need more help from community. It would be glad for me or others, if anyone found solution.

@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label Jun 12, 2019
@michaelr524
Copy link

Looking for a solution as well.

@stale
Copy link

stale bot commented Jul 17, 2019

Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Jul 17, 2019
@stale
Copy link

stale bot commented Aug 1, 2019

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: messaging FCM only - ( messaging() ) - do not use for Notifications Type: Stale Issue has become stale - automatically added by Stale bot
Projects
None yet
Development

No branches or pull requests

7 participants