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.










share|improve this question
























  • 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















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.










share|improve this question
























  • 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













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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












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);
}

}





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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);
    }

    }





    share|improve this answer

























      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);
      }

      }





      share|improve this answer























        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);
        }

        }





        share|improve this answer












        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);
        }

        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 at 17:36









        Luis Aguilar

        818




        818






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Schultheiß

            Verwaltungsgliederung Dänemarks

            Liste der Kulturdenkmale in Wilsdruff