NotificationCompat.Builder(getApplicationContext(),CHANNEL_ID)在Oreo Firebase通知上不起作用 [英] NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) not working on Oreo Firebase notification

查看:95
本文介绍了NotificationCompat.Builder(getApplicationContext(),CHANNEL_ID)在Oreo Firebase通知上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Oreo版本中的Firebase显示通知,因此在获得解决方案时未显示
NotificationCompat.Builder(this, CHANNEL_ID),但它向我显示了这样的内容

I am trying to show notification using Firebase in Oreo version so it's not showing when I get Solution
NotificationCompat.Builder(this, CHANNEL_ID) but it's showing me like this

我的build.gradle文件是

    apply plugin: 'com.android.application'

    dependencies {
    compile project(':library')
    compile project(':camerafragment')
    compile 'com.google.android.gms:play-services:11.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mcxiaoke.volley:library:1.0.17'
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    compile 'com.android.support:cardview-v7:26.0.0-alpha1'
    compile 'com.google.firebase:firebase-messaging:11.0.0'
    compile 'com.google.android.gms:play-services-maps:11.0.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.google.android.gms:play-services-auth:11.0.0'
    compile 'net.gotev:uploadservice:2.1'
    compile 'com.google.firebase:firebase-auth:11.0.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.android.support:support-v4:26.0.0-alpha1'
    }

    android {

    compileSdkVersion 27
    buildToolsVersion "27.0.0"
    dexOptions {
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "com.trashmap"
        minSdkVersion 17
        targetSdkVersion 27

        // Enabling multidex support.
        multiDexEnabled true
        versionCode 17
        versionName "1.16"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
           // shrinkResources true//new add to reduce size
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }



      sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

apply plugin: 'com.google.gms.google-services'

推荐答案

NotificationCompat.Builder (Context context)

此构造函数在API级别26.1.0中已弃用.

This constructor was deprecated in API level 26.1.0.

改为使用NotificationCompat.Builder(Context, String).所有发布的通知必须指定一个NotificationChannel ID.

use NotificationCompat.Builder(Context, String) instead. All posted Notifications must specify a NotificationChannel Id.

您已经定义了compile 'com.android.support:support-v4:26.0.0-alpha1',因此您必须更改支持库的版本号.

And you have defined compile 'com.android.support:support-v4:26.0.0-alpha1' So you have to change your version number of support library.

这篇关于NotificationCompat.Builder(getApplicationContext(),CHANNEL_ID)在Oreo Firebase通知上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆