I am implementing and Android application to send and receive push notifications using Aerogear and OpenShift. I am having an issue to unregister the device, if I open the app and I register the device it works,I can send notifications and all works good, if I try to unregister the device also works well, my problem is when I close the app and my device is registered, if i relaunch the app and I want to unregister the devices i am getting this error:
"The server returned the error code 404"
07-11 21:07:32.436 21158-21245/? D/GCM﹕ GcmService start Intent { act=com.google.android.c2dm.intent.UNREGISTER pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService (has extras) } com.google.android.c2dm.intent.UNREGISTER 07-11 21:07:32.606 20520-20520/? D/wpa_supplicant﹕ RX ctrl_iface - hexdump(len=11): 53 49 47 4e 41 4c 5f 50 4f 4c 4c 07-11 21:07:32.606 20520-20520/? D/wpa_supplicant﹕ wlan0: Control interface command 'SIGNAL_POLL' 07-11 21:07:32.606 20520-20520/? D/wpa_supplicant﹕ nl80211: survey data missing!
This is my actual code
btnRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
RegistrarManager.config(PUSH_REGISTER_NAME, AeroGearGCMPushConfiguration.class)
.setPushServerURI(new URI(UNIFIED_PUSH_URL))
.setSenderIds(GCM_SENDER_ID)
.setVariantID(VARIANT_ID)
.setSecret(SECRET)
.setAlias(ALIAS)
.setDeviceToken(ALIAS)
.asRegistrar();
PushRegistrar registrar = RegistrarManager.getRegistrar(PUSH_REGISTER_NAME);
registrar.register(getActivity().getApplicationContext(), new Callback<Void>() {
@Override
public void onSuccess(Void ignore) {
Toast.makeText(getActivity(), "SUCCESS", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Exception exception) {
Toast.makeText(getActivity(), exception.getMessage(), Toast.LENGTH_SHORT).show();
}
});
} catch (Exception e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
btnUnregister = (Button)mInflatedView.findViewById(R.id.btnUnregister);
btnUnregister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
RegistrarManager.config(PUSH_REGISTER_NAME, AeroGearGCMPushConfiguration.class)
.setPushServerURI(new URI(UNIFIED_PUSH_URL))
.setSenderIds(GCM_SENDER_ID)
.setVariantID(VARIANT_ID)
.setSecret(SECRET)
.setAlias(ALIAS)
.setDeviceToken(ALIAS)
.asRegistrar();
PushRegistrar registrar = RegistrarManager.getRegistrar(PUSH_REGISTER_NAME);
registrar.unregister(getActivity().getApplicationContext(), new Callback<Void>() {
@Override
public void onSuccess(Void ignore) {
Toast.makeText(getActivity(), "SUCCESS", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Exception exception) {
Toast.makeText(getActivity(), exception.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}catch(Exception e){
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
Any advice to solve this?