Can't receive notifications when app is closed or in background
See original GitHub issuemanifest 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:
- Created 7 years ago
- Reactions:1
- Comments:34 (4 by maintainers)
Top GitHub Comments
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.
bump