Hi guys
I got a problem with the GCMRegister Library. I studied the sample project for push notifications. Now i have a problem, that i didn't got a device register id. i builded the code up like in the sample. I think the library didn't register the application, but i don't know why.
Had anyone else the same problem? i put the code also in this topic. The main problem I got, is that deviceRegId is always empty. Maybe someone have a solution. I execute this methode in my MainActivity in a AsyncTask.
public static void registerWithApp42(String projectNo) {
App42Log.debug(" ..... Registeration Check ....");
App42GCMService.setSenderId(projectNo);
final String deviceRegId = GCMRegistrar.getRegistrationId(App42API.appContext);
if (deviceRegId.equals("")) {
// Automatically registers application on startup.
Log.d("App Push Register", "Register task execute");
GCMRegistrar.register(App42API.appContext, projectNo);
} else {
App42Log.debug(" Registering on Server ....");
App42API.buildPushNotificationService().storeDeviceToken(App42API.getLoggedInUser(), deviceRegId, new App42CallBack() {
@Override
public void onSuccess(Object paramObject) {
// TODO Auto-generated method stub
App42Log.debug(" ..... Registeration Success ....");
Log.d("App Push Register", "Registered");
GCMRegistrar.setRegisteredOnServer(App42API.appContext, true);
}
@Override
public void onException(Exception paramException) {
App42Log.debug(" ..... Registeration Failed ....");
App42Log.debug("storeDeviceToken : Exception : on start up " +paramException);
Log.d("App Push Register", "Register failed");
}
});
}