首页 > 解决方案 > 如何解决“此广告系列针对 0 个应用用户(0% 的潜在用户)”。(火力基地)(安卓)

问题描述

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

在此处输入图像描述

我的 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'
}

我的清单就是这样

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

因此,当我启动应用程序时,会出现一个刷新令牌,但 firebase 仪表板中没有出现任何内容,我将包名称、SHA1 添加到 firebase 并下载 google-services.json 并添加到项目级别,但仍然存在发送通知的问题,也没有出现在移动也不是logcat

如何解决?

标签: androidfirebasepush-notificationnotificationsfirebase-cloud-messaging

解决方案


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

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


推荐阅读