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.

Can't receive notifications when app is closed or in background

See original GitHub issue

manifest file:

<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
        android:name="co.my.packagename.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
<uses-permission android:name="co.my.packagename.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

in the application: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

    `<receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="co.my.packagename" />
        </intent-filter>
    </receiver>`

    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>


    <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>

    <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>

settings.gradle:

include ':app' ... include ':react-native-push-notification' project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')

build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:1.2.0'

}

`

app/build.gradle ` dependencies { compile fileTree(dir: “libs”, include: [“*.jar”]) compile “com.android.support:appcompat-v7:23.0.1” compile ‘com.android.support:support-v4:19.1.+’ … compile project(‘:react-native-push-notification’)

compile ('com.google.android.gms:play-services-gcm:8.1.0')

}

Mainapp.java

import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;

@Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), ... new ReactNativePushNotificationPackage() ); } };

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:34 (4 by maintainers)

github_iconTop GitHub Comments

20reactions
npomfretcommented, Oct 6, 2016

My app receives GCM push notifications when it is in the background, tested on Android 4.1 and 5.1.

It doesn’t receive push notifications when its not running though. Although, I’m not sure that feature is supported yet.

7reactions
ddobby94commented, Oct 3, 2016

bump

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
How to get Windows Mail notifications when the app is closed?
I would like to receive notifications while the app is closed, or at least find a way to minimize the app to the...
Read more >
Push Notifications when app is closed - android - Stack Overflow
Yes, it is possible 'to receive notifications from google cloud message when the application is fully closed'. Infact, A broadcast receiver ...
Read more >
Why can't my phone receive App push, incoming call, device ...
Check Notifications Settings, whether Do-Not-Disturb Schedule was on. If your mobile phone and device allow the app to push messages but do not ......
Read more >
How to Fix Notifications Not Showing up on Android - Lifewire
Make sure you haven't turned off app notifications. If you aren't receiving notifications from a specific app, the most likely culprit is ...
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