Android 5.1 push notification icon is blank

后端 未结 4 1353
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-13 06:33

When using Parse for push notifications our app always displayed the application\'s launcher icon. In the latest Android 5.1 version, the icon appears to be blank (a white squar

4条回答
  •  抹茶落季
    2021-02-13 06:49

    You must use a transparent and white icon under Android Lollipop 5.0 or greater. You can extend ParsePushBroadcastReceiver class and override the two methods to get your notification icon compatible with these Android APIs.

        @Override
    protected int getSmallIconId(Context context, Intent intent) {
        return R.drawable.your_notifiation_icon;
    }
    
    @Override
    protected Bitmap getLargeIcon(Context context, Intent intent) {
        return BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon);
    }
    

    Remember to customize your code to support Lollipop and previous APIs.

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            return BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon_lollipop);
        }
        else{
            return BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon);
        }
    

提交回复
热议问题