android - 如何解决 "This campaign targets 0 app user(s) (0% of potential users)."(Firebase) (Android)

标签 android firebase push-notification notifications firebase-cloud-messaging

我在 Firebase 云消息传递中遇到问题,因为我只从 Firebase 使用它,直到现在都没有工作
当我从 Firebase 的通知压缩器发送通知时,它会这样显示我

enter image description here

我的 build.gradle (项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的 build.gradle(应用程序)
    apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.***"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
...
    implementation('com.google.android.gms:play-services-base:16.0.1') {
        exclude module: 'support-v4'
    }

    implementation('com.google.android.gms:play-services-maps:16.0.0') {
        exclude module: 'support-v4'
    }

    implementation('com.google.android.gms:play-services-places:16.0.0') {
        exclude module: 'support-v4'
    }
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.google.firebase:firebase-iid:17.0.4'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
}

我的 list 就是这样
 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.**">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:name=".ApplicationClass"
        android:allowBackup="true"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:roundIcon="@drawable/app_icon"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:name=".MainActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="***"/>

        <activity
            android:name=".LoginActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <service
            android:name=".MyFirebaseInstanceIDService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <meta-data
          android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/logo" />
    </application>
</manifest>

这是我在登录中所做的,这是要显示的第一个屏幕
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
        @Override
        public void onSuccess(InstanceIdResult instanceIdResult) {
            refreshedToken = instanceIdResult.getToken();
            Log.e("refreshedToken", refreshedToken);
            // Do whatever you want with your token now
            // i.e. store it on SharedPreferences or DB
            // or directly send it to server
        }
    });

因此,当我启动应用程序时,会出现一个刷新 token ,但 firebase 仪表板中什么也没有出现
我加了
包裹名字,
SHA1
到firebase并下载
谷歌服务.json
并添加到项目级别,但仍然存在发送通知的问题
手机和logcat上也没有出现任何内容

如何解决?

最佳答案

您可以清理项目并重建它。它会起作用,

为什么它不起作用是 - 您一定已经删除了 google-services.json 文件并重新添加了它。

关于android - 如何解决 "This campaign targets 0 app user(s) (0% of potential users)."(Firebase) (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54256220/

相关文章:

android - 使用 wget 获取适用于 Ubuntu 的最新版本的 Android SDK

安卓游戏UDP/TCP?

ios - 使用 Firebase 和 OneSignal 推送通知

iOS APNS - 应用程序从商店中删除后,通知是否仍会发送到设备

ios - 推送通知如何在 iOS 的移动设备管理中工作?

java - 推送通知在 Android 中不起作用,代号一

android - Firebase onChildAdded 第一次为空

android - 屏幕一分为二(水平或垂直)

java - 从 firebase android 检索图像的简单方法

javascript - 无法读取 firebase 函数中未定义错误的属性 https