I try to implement system to receive push notifications on my application.
I use Firebase and everything is ok when the app is active or in background but nothing happen when the app is closed.
I tried to create a WakefullBroadcastReceiver
like that :
public class NotificationReceiver extends WakefulBroadcastReceiver {
public static final String action = "com.myapp.notification.RECEIVE";
private static final String KEY_PUSH_DATA = "com.parse.Data";
@Override
public void onReceive(Context context, Intent intent) {
String intentAction = intent.getAction();
switch (intentAction) {
case action:
String pushDataStr = intent.getStringExtra(KEY_PUSH_DATA);
if (pushDataStr == null) {
return;
}
Log.e("PUSH", "Push data : "+pushDataStr);
Bundle extras = intent.getExtras();
MyappNotificationManager.getInstance().parseBundle(extras);
break;
}
}
}
and I add this in Manifest.xml
<receiver android:name=".notification.NotificationReceiver">
<intent-filter>
<action android:name="com.myapp.notification.RECEIVE"/>
</intent-filter>
</receiver>
It doesn't work and I can't find documentation on Android developper website.
Thanks for your help.