diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp --- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp @@ -13,6 +13,10 @@ #include #include +#ifdef __ANDROID__ +#include +#endif + namespace comm { using namespace facebook::react; @@ -800,8 +804,15 @@ }); } try { - NotificationsCryptoModule::initializeNotificationsCryptoAccount( - "Comm"); + auto task = []() { + NotificationsCryptoModule::initializeNotificationsCryptoAccount( + "Comm"); + }; +#ifdef __ANDROID__ + facebook::jni::ThreadScope::WithClassLoader(std::move(task)); +#else + task(); +#endif } catch (const std::exception &e) { error = e.what(); } @@ -833,8 +844,15 @@ } try { if (!error.size()) { - notificationsKeysResult = - NotificationsCryptoModule::getNotificationsIdentityKeys(); + auto task = [¬ificationsKeysResult]() { + notificationsKeysResult = + NotificationsCryptoModule::getNotificationsIdentityKeys(); + }; +#ifdef __ANDROID__ + facebook::jni::ThreadScope::WithClassLoader(std::move(task)); +#else + task(); +#endif } } catch (const std::exception &e) { error = e.what();