Skip to content

Commit 4f89e04

Browse files
author
Bhakta
committed
Fixed for app crash if push configured
(cherry picked from commit aff0794)
1 parent 030753a commit 4f89e04

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/commonAPI/coreapi/ext/shared/PushImpl.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ namespace push {
3737
//----------------------------------------------------------------------------------------------------------------------
3838
CPushManager* CPushManager::getInstance()
3939
{
40-
return reinterpret_cast<CPushManager*>(CPushFactoryBase::getInstance()->getModuleSingleton());
40+
CPushFactoryBase* pInstance = CPushFactoryBase::getInstance();
41+
if (pInstance){
42+
LOG(TRACE) + "Returning CPushManager Instance";
43+
return reinterpret_cast<CPushManager*>(pInstance->getModuleSingleton());
44+
}else{
45+
LOG(TRACE) + "CPushFactoryBase::getInstance is empty. Returning 0";
46+
return 0;
47+
}
4148
}
4249

4350
//----------------------------------------------------------------------------------------------------------------------

platform/android/Rhodes/jni/src/rhodesapp.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,12 @@ RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesService_setPushRegistrat
332332
std::string strType = jType ? rho_cast<std::string>(env, jType) : "";
333333
std::string deviceId = rho_cast<std::string>(env, jId);
334334

335-
rho::push::CPushManager::getInstance()->setDeviceId(strType, deviceId);
335+
rho::push::CPushManager* pInstance = rho::push::CPushManager::getInstance();
336+
if (pInstance){
337+
pInstance->setDeviceId(strType, deviceId);
338+
}else{
339+
RAWTRACE("rho::push::CPushManager::getInstance is empty");
340+
}
336341
}
337342

338343
RHO_GLOBAL jboolean JNICALL Java_com_rhomobile_rhodes_RhodesService_callPushCallback

0 commit comments

Comments
 (0)