
[英]Which component of Android does receive the google cloud messaging message
[英]Google Cloud Messaging inside Knox. How to receive a message?
我的应用程序在Knox内从GCM接收消息时遇到了一个大问题。 Knox之外的同一个应用程序可以毫无问题地接收消息。 同一应用在内部和外部都向GCM注册。 为什么GCM在Knox内部不起作用? 要在Knox内接收GCM消息怎么办?
Device: Samsung S5
Samsung Knox version: 2.3
Google Play Services: 8.4.89
好的,我自己找到了解决方案。 问题在于注册到GCM服务。
我使用了GCM指南( https://developers.google.com/cloud-messaging/android/start )中的注册代码:
public class RegistrationIntentService extends IntentService {
@Override
public void onHandleIntent(Intent intent) {
// ...
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
// ...
}
}
实际上,它运行良好。 在Android和Knox中,按预期收到令牌。 但是在Knox上,GCM没有任何消息。 在查看了各种应用程序之后,我使用了不同的代码进行注册:
public class RegistrationIntentService extends IntentService {
@Override
public void onHandleIntent(Intent intent) {
// ...
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
String token = gcm.register(getString(R.string.gcm_defaultSenderId));
// ...
}
}
...神奇的是。 希望它对某人有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.