question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: Can't get push notification when app is off

See original GitHub issue

Im able to get push notification when app is on or in background, but then app is off with task manager I didn’t get nothing

When I try to use only FCM dashboard Im getting it even if app is off

android/app/build.grandle

    compile(project(':react-native-fcm')) {
      exclude group: "com.google.firebase"
    }
    compile ('com.google.firebase:firebase-core:11.+') {
        force = true;
    }
    compile ('com.google.firebase:firebase-messaging:11.+') {
        force = true;
    }
    compile('io.intercom.android:intercom-sdk-base:4.+') {
        force = true;
    }
    compile('io.intercom.android:intercom-sdk-fcm:4.+') {
        force = true;
    }

AndroidManifest.xml

    <application
      android:name="io.bla.bla.MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme"
      xmlns:tools="http://schemas.android.com/tools">
.....
      <service
        android:name="com.robinpowered.react.Intercom.IntercomIntentService"
        android:exported="false">
        <intent-filter
            android:priority="999">
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        </intent-filter>
    </service>

    <receiver
     android:name="io.intercom.android.sdk.push.IntercomPushBroadcastReceiver"
     tools:replace="android:exported"
     android:exported="true" />
    </application>

permisions from AndroidManifest.xml

    <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.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:12

github_iconTop GitHub Comments

4reactions
Rajat421commented, Jul 20, 2018

@akyker20 I am using intercom in my project and able to get push notification. I am taking help from react-native-firebase. What I did was created a CustomFCMMessageService.java in same directory where mainApplication.java is present.

`package com.xxx.xxx;

import java.util.Map; import android.util.Log; import com.google.firebase.messaging.RemoteMessage; import com.webengage.sdk.android.WebEngage; import io.invertase.firebase.messaging.RNFirebaseMessagingService; import io.intercom.android.sdk.push.IntercomPushClient;

public class CustomFCMMessageService extends RNFirebaseMessagingService { private static final String TAG = “CustomFCMMessageService”;

private final IntercomPushClient intercomPushClient = new IntercomPushClient();

@Override

public void onMessageReceived(RemoteMessage remoteMessage) {
    Map message = remoteMessage.getData();

    Log.d("MessageReceived", "" + message);
    //Webengage

    if (message != null) {
        if (intercomPushClient.isIntercomPush(message)) {
            Log.d(TAG, "Intercom message received");
            intercomPushClient.handlePush(getApplication(), message);
        }  else {
            super.onMessageReceived(remoteMessage);
            Log.d(TAG, "NATIVE message received");

        }
    }
}

}

` I am using Firebase messaging service to detect push notification.

then in AndroidManifest.xml

add this <service android:name=".CustomFCMMessageService" // replacing firebase messaging service as suggested by doc android:enabled="true" android:exported="true"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>

Hope this will help 😃

2reactions
fryossicommented, Jan 15, 2018

@tobob It seems that you’re using the action for GCM. try to replace with <action android:name="com.google.firebase.MESSAGING_EVENT"/>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Push Notifications when app is closed - android - Stack Overflow
In Android 8.0 Oreo if the application is closed, then notification is not received It is because of DOZE mode and battery optimization,you...
Read more >
Android Notifications Not Showing Up? 10 Fixes You Can Try
Not seeing notifications show up on your Android phone? Try these fixes to get Android notifications working again.
Read more >
Android device cannot receive push notifications when an ...
Android device cannot receive push notifications when an application is force stopped ("killed") · Go to Settings > Apps & Notifications > enable ......
Read more >
Android push notification not working when the app is closed
So the situation is like, all are getting the notification as per their custom modification done in the app but some devices are...
Read more >
How to Fix Notifications Not Showing up on Android - Lifewire
Cause of Notifications Not Showing up on Android · Do Not Disturb or Airplane Mode is on. · Either system or app notifications...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found