Hey,
I’m trying to implement your SDK into our android app. Push notifications are working fine but only when app is opened or it is in tray. When the app is closed push notification is never being delivered.
This is your approach from SDK README, and it works as described above
public class PushNotificationService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("FIREBASE_PUSH_NOTIFICATIONS ", "Notification received");
super.onMessageReceived(remoteMessage);
new KlaviyoNotification(remoteMessage).displayNotification(this);
I tried also basic firebase implementation without Klaviyo, and it works even with app closed
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("FIREBASE_PUSH_NOTIFICATIONS ", "Notification received");
super.onMessageReceived(remoteMessage);
remoteMessage.getData().forEach((key, value) -> System.out.println(key + ":" + value));
Intent intent = new Intent(this, PushNotificationService.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
String channelId = "Default";
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.setSmallIcon(1)
.setContentTitle("test")
.setContentText("body").setAutoCancel(true).setContentIntent(pendingIntent);;
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "Default channel", NotificationManager.IMPORTANCE_DEFAULT);
manager.createNotificationChannel(channel);
}
manager.notify(0, builder.build());
}
Is it a bug in your implementation?
Looking for support to solve this problem :)
Best answer by Evan.Masseau
View original