私はfirebaseメッセージを使用してプッシュ通知を送信しています。 Google Playサービス(バージョン3.2.25)がインストールされたAndroidバージョン4.1.2を搭載したデバイスを使用してテストしましたが、正常に動作するとonMessageReceived
が正しく呼び出されます。しかし、Android 2.3.6と最後のGoogle Playサービス(それをインストールしなければならない)を実行しているデバイスを使ってテストしようとすると、Firebase Web UIが正常に送信されたと表示されてもメッセージは届きません。Android 2.3.6でFirebase Messagingが動作しない
9.4.0バージョンを使用するように指定されていても、古いGoogle Playサービスで動作している新しいAndroidで動作する理由と、それが他のシナリオでは機能しないのはなぜですか。
Build.gradle(アプリ)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.sipas"
minSdkVersion 10
targetSdkVersion 24
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-v4:24.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'me.dm7.barcodescanner:zbar:1.9'
compile 'com.google.code.gson:gson:2.4'
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okio:okio:1.9.0'
compile 'com.birbit:android-priority-jobqueue:2.0.0'
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
Build.gradle(プロジェクト)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
FWIW - Play Services 9.4.52を使用して2.3.6を実行する古いデバイスでFirebaseコンソールから送信された通知を受信できました。私はFirebase 9.4.0を使ってテストアプリケーションをビルドします。電話には非常に古いバージョンのPlayサービスがあるため、私の最初の試行は失敗しました。使用しているPlayサービスのバージョンは何ですか? –
私は最後のバージョンをインストールしました。私のデバイスと互換性がないかもしれないが、私はそれをインストールした後にgetTokenメソッドがトークンを返すようになったので、そうではないと信じている。 –
トークンを取得していますが、メッセージを受信していませんか?あなたはあなたの質問に、あなたが非現実的なケースで使用しているgradleの依存関係を追加できますか? FCMはSDK 9から動作するはずです。したがって、2.3.6は問題ではありません。 –