0
votes

This code is not generating the push.

//        intent used to click on notification
    Intent intent = new Intent(this, AdminMainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

// custom notification view RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_push); contentView.setImageViewResource(R.id.image, R.mipmap.ic_launcher); contentView.setTextViewText(R.id.title, "mSchooling"); contentView.setTextViewText(R.id.text, message); // notification code final String CHANNEL_ID = "channel_02"; NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, getString(R.string.app_name), NotificationManager.IMPORTANCE_DEFAULT); mNotificationManager.createNotificationChannel(mChannel); } NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setColor(Color.RED) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentTitle("mSchooling") .setContent(contentView) .setContentIntent(pendingIntent); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { builder.setChannelId(CHANNEL_ID); // Channel ID } builder.setAutoCancel(true); mNotificationManager.notify(1, builder.build());

1
can you show log of error?droidbaza
I am not getting any error, the code is debugging as well but not generating the push.Shadab Azam Farooqui
Where are you generating the notification? A background service? Receiver? If you're starting from the background, then try checking if the background thread even startsAmin
notification is coming from FCM, when i am debugging the code, line by line is running but push is not coming.Shadab Azam Farooqui
i am checking in android 10Shadab Azam Farooqui

1 Answers

0
votes

I am using custom layout for push in which i have a custom textview, simply i replaced the custom textview with default, push has worked .