1

I have a big problem with receiving a message from GCM inside Knox by my app. The same app outside of the Knox receives messages without any problem. The same app registers to the GCM outside as well inside. Why the GCM doesn't work inside Knox? What has to be done to receive the GCM message inside Knox?

Device: Samsung S5
Samsung Knox version: 2.3
Google Play Services: 8.4.89
Arkadiusz Cieśliński
  • 5,307
  • 3
  • 23
  • 19

1 Answers1

1

OK, I have found the solution myself. The problem was with registration to the GCM service.

I used code for registration from the GCM guide (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);

        // ...
    }
}

Actually it was working good. In Android and Knox the token was received as expected. But on Knox was no any message from GCM. After reviewing various apps I used different code for registration:

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));

        // ...
    }
}

... and magically that was it. Hope it will be useful for somebody.


Arkadiusz Cieśliński
  • 5,307
  • 3
  • 23
  • 19