You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dont recived notification when app in background or killed just on android 8 and later #941
push notification display in my app in android 8 and later when app is open but when app are in bakground or killed dont display
but in lower version i havent problems
public class MyFirebaseMessagingService extends FirebaseMessagingService {
public final String CHANEL_ID="088";
public static final String TAG="firebasemessage";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "onMessageReceived: ");
sendNotification(remoteMessage.getNotification().getBody());
}
//This method is only generating push notification
//It is same as we did in earlier posts
private void sendNotification(String messageBody) {
Log.d(TAG,messageBody);
createNotification(messageBody);
}
private void createNotification(String messageBody) {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
Log.d(TAG, "createNotification: ");
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
String channelId = getString(R.string.default_notification_channel_id);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.mipmap.icon)
.setContentTitle("bigbag")
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Since android Oreo notification channel is needed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId,
"Channel human readable title",
NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
}
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
Activity
google-oss-bot commentedon Sep 2, 2019
This issue does not seem to follow the issue template. Make sure you provide all the required information.
mehdidavarpanah66 commentedon Sep 2, 2019
this is mani fest
mehdidavarpanah66 commentedon Sep 2, 2019
package www.partopars.com.bigbag.Firebase;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import www.partopars.com.bigbag.Main.MainActivity;
import www.partopars.com.bigbag.R;
/**
*
*/
public class MyFirebaseMessagingService extends FirebaseMessagingService {
public final String CHANEL_ID="088";
public static final String TAG="firebasemessage";
// Intent intent = new Intent(this, MainActivity.class);
//
//
//
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
// PendingIntent.FLAG_ONE_SHOT);
//
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Log.d(TAG, "createNotification: "+Build.VERSION.SDK_INT);
// int importance = NotificationManager.IMPORTANCE_DEFAULT;
// NotificationChannel channel = new NotificationChannel(CHANEL_ID, "088", importance);
// channel.setDescription("bigbag");
// // Register the channel with the system; you can't change the importance
// // or other notification behaviors after this
// NotificationManager notificationManager = getSystemService(NotificationManager.class);
// notificationManager.createNotificationChannel(channel);
// Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
//
//
// Notification.Builder builder=new Notification.Builder(getApplicationContext(),CHANEL_ID)
// .setSmallIcon(R.mipmap.icon)
// .setContentTitle("گروه تجاری بیگ بگ")
// .setContentText(messageBody)
// .setSound(defaultSoundUri)
// .setContentIntent(pendingIntent)
// .setAutoCancel(true)
// .setPriority(Notification.PRIORITY_DEFAULT);
//
// NotificationManagerCompat notificationManagerCompat=NotificationManagerCompat.from(getApplicationContext());
// notificationManager.notify(001,builder.build());
// }else{
// Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
// NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
// .setSmallIcon(R.mipmap.icon)
// .setContentTitle("گروه تجاری بیگ بگ")
// .setContentText(messageBody)
// .setSound(defaultSoundUri)
// .setAutoCancel(true)
// .setContentIntent(pendingIntent);
//
// Notification notification = notificationBuilder.build();
// //notification.sound=Uri.parse("android.resource://www.partopars.com.musicplayer/" + R.raw.apple_ring);
//
// NotificationManager notificationManager =
// (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//
// notificationManager.notify(0, notification);
// }
}
}
KORuL commentedon Oct 8, 2019
#822
ambr89 commentedon Dec 18, 2019
Does anyone found the solution?
I've Android device and I receive the push message only if ap is in the background but not killed.
Android 8.0.0