小编Yas*_*ain的帖子

FireBase云消息传递不起作用

我正在尝试使用FireBase云消息传递.我收到一个令牌,但它没有从控制台收到任何通知.这是我的清单:

  <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="careerage.jobseeker.app"
android:hardwareAccelerated="true"
android:versionCode="1"
android:versionName="0.0.1">

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="23" />

<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

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

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

<application
    android:hardwareAccelerated="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:supportsRtl="true">
    <activity
        android:name=".MainActivity"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
        android:label="@string/activity_name"
        android:launchMode="singleTop"
        android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
        android:windowSoftInputMode="adjustResize">
        <intent-filter android:label="@string/launcher_name">
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".TokenService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service>
    <service
        android:name=".NotificationService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>
</application>
Run Code Online (Sandbox Code Playgroud)

而我的代码几乎与样本相同:

public class NotificationService extends FirebaseMessagingService {

private void …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-cloud-messaging

8
推荐指数
1
解决办法
7590
查看次数

Gradle未编译Firebase云消息传递

我注意到Firebase API已从v 9.0.0升级到v 9.0.1,因此决定更改它.

然而,它没有被注意到.

这是Gradle Logcat中的错误

   Error:(25, 13) Failed to resolve: com.google.firebase:firebase-messaging:9.0.1
   Error:(26, 13) Failed to resolve: com.google.firebase:firebase-core:9.0.1
Run Code Online (Sandbox Code Playgroud)

这是我的Gradle文件

Build.Gradle-> App

  apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.example.lifeline.applicationgreat"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.firebase:firebase-core:9.0.1'
}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

Build.Gradle-> Project

     // Top-level build …
Run Code Online (Sandbox Code Playgroud)

android gradle firebase-cloud-messaging

4
推荐指数
2
解决办法
9365
查看次数