Heads up push notification not doing the Pop up function
up vote
0
down vote
favorite
I am new to Android and I have been trying to show a Heads up action push notification just like whatsapp does.
This is my configuration for my notification:
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, ADMIN_CHANNEL)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_foreground))
.setSmallIcon(R.drawable.m_icon)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setTicker(remoteMessage.getNotification().getBody())
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.mblue))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(remoteMessage.getNotification().getBody()))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(likePendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificationBuilder.build());
I have read in some post that the key to acomplish this is to set high priority to the notification but, It is still not working for me.
java android android-studio push-notification
|
show 2 more comments
up vote
0
down vote
favorite
I am new to Android and I have been trying to show a Heads up action push notification just like whatsapp does.
This is my configuration for my notification:
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, ADMIN_CHANNEL)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_foreground))
.setSmallIcon(R.drawable.m_icon)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setTicker(remoteMessage.getNotification().getBody())
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.mblue))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(remoteMessage.getNotification().getBody()))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(likePendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificationBuilder.build());
I have read in some post that the key to acomplish this is to set high priority to the notification but, It is still not working for me.
java android android-studio push-notification
Are you testing on a device running Oreo or later?
– TheWanderer
Nov 9 at 1:03
Yes, it's a moto g5 plus with one pixel ROM. Android 8.0. It's a rooted phone
– Luis Aguilar
Nov 9 at 1:29
Have you checked the app's notification settings? Check to see whether certain aspects that you want to display are enabled.
– Ishaan
Nov 9 at 1:30
2
@LuisAguilar you set a notification channel name in the Builder's constructor, but are you actually creating that channel? If not, Android will just use some default (probably medium) priority for your notification.
– TheWanderer
Nov 9 at 1:31
@Ishaan I have not but my notifications from WhatsApp pop up correctly
– Luis Aguilar
Nov 9 at 1:36
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am new to Android and I have been trying to show a Heads up action push notification just like whatsapp does.
This is my configuration for my notification:
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, ADMIN_CHANNEL)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_foreground))
.setSmallIcon(R.drawable.m_icon)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setTicker(remoteMessage.getNotification().getBody())
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.mblue))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(remoteMessage.getNotification().getBody()))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(likePendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificationBuilder.build());
I have read in some post that the key to acomplish this is to set high priority to the notification but, It is still not working for me.
java android android-studio push-notification
I am new to Android and I have been trying to show a Heads up action push notification just like whatsapp does.
This is my configuration for my notification:
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, ADMIN_CHANNEL)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher_foreground))
.setSmallIcon(R.drawable.m_icon)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setTicker(remoteMessage.getNotification().getBody())
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.mblue))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(remoteMessage.getNotification().getBody()))
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(likePendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificationBuilder.build());
I have read in some post that the key to acomplish this is to set high priority to the notification but, It is still not working for me.
java android android-studio push-notification
java android android-studio push-notification
edited Nov 9 at 0:08
asked Nov 8 at 23:50
Luis Aguilar
818
818
Are you testing on a device running Oreo or later?
– TheWanderer
Nov 9 at 1:03
Yes, it's a moto g5 plus with one pixel ROM. Android 8.0. It's a rooted phone
– Luis Aguilar
Nov 9 at 1:29
Have you checked the app's notification settings? Check to see whether certain aspects that you want to display are enabled.
– Ishaan
Nov 9 at 1:30
2
@LuisAguilar you set a notification channel name in the Builder's constructor, but are you actually creating that channel? If not, Android will just use some default (probably medium) priority for your notification.
– TheWanderer
Nov 9 at 1:31
@Ishaan I have not but my notifications from WhatsApp pop up correctly
– Luis Aguilar
Nov 9 at 1:36
|
show 2 more comments
Are you testing on a device running Oreo or later?
– TheWanderer
Nov 9 at 1:03
Yes, it's a moto g5 plus with one pixel ROM. Android 8.0. It's a rooted phone
– Luis Aguilar
Nov 9 at 1:29
Have you checked the app's notification settings? Check to see whether certain aspects that you want to display are enabled.
– Ishaan
Nov 9 at 1:30
2
@LuisAguilar you set a notification channel name in the Builder's constructor, but are you actually creating that channel? If not, Android will just use some default (probably medium) priority for your notification.
– TheWanderer
Nov 9 at 1:31
@Ishaan I have not but my notifications from WhatsApp pop up correctly
– Luis Aguilar
Nov 9 at 1:36
Are you testing on a device running Oreo or later?
– TheWanderer
Nov 9 at 1:03
Are you testing on a device running Oreo or later?
– TheWanderer
Nov 9 at 1:03
Yes, it's a moto g5 plus with one pixel ROM. Android 8.0. It's a rooted phone
– Luis Aguilar
Nov 9 at 1:29
Yes, it's a moto g5 plus with one pixel ROM. Android 8.0. It's a rooted phone
– Luis Aguilar
Nov 9 at 1:29
Have you checked the app's notification settings? Check to see whether certain aspects that you want to display are enabled.
– Ishaan
Nov 9 at 1:30
Have you checked the app's notification settings? Check to see whether certain aspects that you want to display are enabled.
– Ishaan
Nov 9 at 1:30
2
2
@LuisAguilar you set a notification channel name in the Builder's constructor, but are you actually creating that channel? If not, Android will just use some default (probably medium) priority for your notification.
– TheWanderer
Nov 9 at 1:31
@LuisAguilar you set a notification channel name in the Builder's constructor, but are you actually creating that channel? If not, Android will just use some default (probably medium) priority for your notification.
– TheWanderer
Nov 9 at 1:31
@Ishaan I have not but my notifications from WhatsApp pop up correctly
– Luis Aguilar
Nov 9 at 1:36
@Ishaan I have not but my notifications from WhatsApp pop up correctly
– Luis Aguilar
Nov 9 at 1:36
|
show 2 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
The issue is that we have to add a new channel configuration whenever the OS is Oroe. So I had to validate if the OS is Oreo and then asign a channel to my notificationManager:
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
setupChannels();
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void setupChannels(){
CharSequence adminChannelName ="Global channel";
String adminChannelDescription = "Notifications sent from the app admin";
NotificationChannel adminChannel;
adminChannel = new NotificationChannel(ADMIN_CHANNEL_ID, adminChannelName, NotificationManager.IMPORTANCE_HIGH);
adminChannel.setDescription(adminChannelDescription);
adminChannel.enableLights(true);
adminChannel.setImportance(NotificationManager.IMPORTANCE_HIGH);
adminChannel.setLightColor(Color.RED);
adminChannel.enableVibration(true);
if (notificationManager != null) {
notificationManager.createNotificationChannel(adminChannel);
}
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The issue is that we have to add a new channel configuration whenever the OS is Oroe. So I had to validate if the OS is Oreo and then asign a channel to my notificationManager:
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
setupChannels();
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void setupChannels(){
CharSequence adminChannelName ="Global channel";
String adminChannelDescription = "Notifications sent from the app admin";
NotificationChannel adminChannel;
adminChannel = new NotificationChannel(ADMIN_CHANNEL_ID, adminChannelName, NotificationManager.IMPORTANCE_HIGH);
adminChannel.setDescription(adminChannelDescription);
adminChannel.enableLights(true);
adminChannel.setImportance(NotificationManager.IMPORTANCE_HIGH);
adminChannel.setLightColor(Color.RED);
adminChannel.enableVibration(true);
if (notificationManager != null) {
notificationManager.createNotificationChannel(adminChannel);
}
}
add a comment |
up vote
0
down vote
The issue is that we have to add a new channel configuration whenever the OS is Oroe. So I had to validate if the OS is Oreo and then asign a channel to my notificationManager:
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
setupChannels();
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void setupChannels(){
CharSequence adminChannelName ="Global channel";
String adminChannelDescription = "Notifications sent from the app admin";
NotificationChannel adminChannel;
adminChannel = new NotificationChannel(ADMIN_CHANNEL_ID, adminChannelName, NotificationManager.IMPORTANCE_HIGH);
adminChannel.setDescription(adminChannelDescription);
adminChannel.enableLights(true);
adminChannel.setImportance(NotificationManager.IMPORTANCE_HIGH);
adminChannel.setLightColor(Color.RED);
adminChannel.enableVibration(true);
if (notificationManager != null) {
notificationManager.createNotificationChannel(adminChannel);
}
}
add a comment |
up vote
0
down vote
up vote
0
down vote
The issue is that we have to add a new channel configuration whenever the OS is Oroe. So I had to validate if the OS is Oreo and then asign a channel to my notificationManager:
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
setupChannels();
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void setupChannels(){
CharSequence adminChannelName ="Global channel";
String adminChannelDescription = "Notifications sent from the app admin";
NotificationChannel adminChannel;
adminChannel = new NotificationChannel(ADMIN_CHANNEL_ID, adminChannelName, NotificationManager.IMPORTANCE_HIGH);
adminChannel.setDescription(adminChannelDescription);
adminChannel.enableLights(true);
adminChannel.setImportance(NotificationManager.IMPORTANCE_HIGH);
adminChannel.setLightColor(Color.RED);
adminChannel.enableVibration(true);
if (notificationManager != null) {
notificationManager.createNotificationChannel(adminChannel);
}
}
The issue is that we have to add a new channel configuration whenever the OS is Oroe. So I had to validate if the OS is Oreo and then asign a channel to my notificationManager:
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
setupChannels();
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void setupChannels(){
CharSequence adminChannelName ="Global channel";
String adminChannelDescription = "Notifications sent from the app admin";
NotificationChannel adminChannel;
adminChannel = new NotificationChannel(ADMIN_CHANNEL_ID, adminChannelName, NotificationManager.IMPORTANCE_HIGH);
adminChannel.setDescription(adminChannelDescription);
adminChannel.enableLights(true);
adminChannel.setImportance(NotificationManager.IMPORTANCE_HIGH);
adminChannel.setLightColor(Color.RED);
adminChannel.enableVibration(true);
if (notificationManager != null) {
notificationManager.createNotificationChannel(adminChannel);
}
}
answered Nov 9 at 17:36
Luis Aguilar
818
818
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217859%2fheads-up-push-notification-not-doing-the-pop-up-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you testing on a device running Oreo or later?
– TheWanderer
Nov 9 at 1:03
Yes, it's a moto g5 plus with one pixel ROM. Android 8.0. It's a rooted phone
– Luis Aguilar
Nov 9 at 1:29
Have you checked the app's notification settings? Check to see whether certain aspects that you want to display are enabled.
– Ishaan
Nov 9 at 1:30
2
@LuisAguilar you set a notification channel name in the Builder's constructor, but are you actually creating that channel? If not, Android will just use some default (probably medium) priority for your notification.
– TheWanderer
Nov 9 at 1:31
@Ishaan I have not but my notifications from WhatsApp pop up correctly
– Luis Aguilar
Nov 9 at 1:36