【发布时间】:2016-02-16 14:08:15
【问题描述】:
我正在使用 Google Cloud Messaging 在我的 android 应用程序中实现推送通知。 在大多数设备上一切正常,但是当我在 Samsung Galaxy S Dous GT-S7562 (Android 4.0.4, API 15) 上测试应用程序时,当我发送通知时,它不会调用onMessageReceived() 方法。
由于在其他设备上一切正常,我很确定我的代码的功能。 我使用下面的代码检查 GooglePlayServices 的可用性,它返回 true :
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
虽然 RegistrationIntentService() 将设备的令牌发送到我的服务器,并且 GCM 调用来自我的服务器响应“success”,但该应用不会调用 onMessageRecieved() 方法,因为我把日志放在它的开头。
还有什么我必须检查才能调试问题的吗?
感谢您的帮助。
【问题讨论】:
-
您找到解决方案了吗? FCM 也发生在我身上。
标签: java android android-studio notifications google-cloud-messaging