diff --git a/native/android/app/src/cpp/PlatformSpecificTools.cpp b/native/android/app/src/cpp/PlatformSpecificTools.cpp --- a/native/android/app/src/cpp/PlatformSpecificTools.cpp +++ b/native/android/app/src/cpp/PlatformSpecificTools.cpp @@ -24,6 +24,13 @@ } return result; } + + static std::string getNotificationsCryptoAccountPath() { + static const auto cls = javaClassStatic(); + static auto method = + cls->getStaticMethod("getNotificationsCryptoAccountPath"); + return method(cls)->toStdString(); + } }; namespace comm { @@ -40,4 +47,12 @@ return std::string{"android"}; } +std::string PlatformSpecificTools::getNotificationsCryptoAccountPath() { + std::string path; + NativeAndroidAccessProvider::runTask([&path]() { + path = PlatformSpecificToolsJavaClass::getNotificationsCryptoAccountPath(); + }); + return path; +} + } // namespace comm diff --git a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h --- a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h +++ b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h @@ -8,6 +8,7 @@ public: static void generateSecureRandomBytes(crypto::OlmBuffer &buffer, size_t size); static std::string getDeviceOS(); + static std::string getNotificationsCryptoAccountPath(); }; } // namespace comm diff --git a/native/ios/Comm/PlatformSpecificTools.mm b/native/ios/Comm/PlatformSpecificTools.mm --- a/native/ios/Comm/PlatformSpecificTools.mm +++ b/native/ios/Comm/PlatformSpecificTools.mm @@ -23,4 +23,18 @@ return std::string{"ios"}; } +std::string PlatformSpecificTools::getNotificationsCryptoAccountPath() { + NSURL *groupUrl = [NSFileManager.defaultManager + containerURLForSecurityApplicationGroupIdentifier:@"group.app.comm"]; + if (groupUrl == nil) { + throw std::runtime_error( + "Failed to resolve notifications crypto account path - could not find " + "groupUrl"); + } + return std::string( + [[groupUrl + URLByAppendingPathComponent:@"comm_notifications_crypto_account"] + .path UTF8String]); +} + }; // namespace comm