FCM android推送通知在firebase控制台上运行,但不在后端

时间:2017-10-19 06:14:48

标签: android firebase push-notification backend

如果我通过firebase控制台发送通知,它在我的应用程序上工作得非常好,但是当我通过后端发送通知时,通知不会出现,但通知的信息会发布到我的firebase数据库中,请我需要一些帮助。

Android清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acorn.wts">

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

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".loginActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Consumo" />
    <activity android:name=".Variables" />
    <activity android:name=".Flujo" />
    <activity android:name=".MainActivity" />

    <service android:name=".FirebaseMessaging">
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
    <service android:name=".FirebaseInstanceIdService">
        android:enabled="true"
        android:exported="true">
        <intent-filter>

            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
            android:enabled="true"
            android:exported="true">
        </intent-filter>
    </service>


    <activity android:name=".InfoActivity" />
    <activity android:name=".Tiempo_Llenado"></activity>
</application>

Andoid gradle:

buildscript {
repositories {
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.0.0'



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

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

Android版本:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "acorn.wts"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:9.0.1'
compile 'com.google.firebase:firebase-database:9.0.1'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.android.gms:play-services-auth:9.0.1'
compile 'com.google.firebase:firebase-auth:9.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
testCompile 'junit:junit:4.12'
}

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

使用推进休息客户的通知:

   {
   "to": "d8IVNp4Q9tLqL45PNtUP4B1Yr3ABhNWC4UccWdzUwHCCZw31YM3Moc_nt...-",
   "notification": {
   "body": "great match!",
   "title": "Portugal vs. Denmark",
   "icon": "myicon"
    }
    }

0 个答案:

没有答案
相关问题