///
/// JHybridOneNotificationsSpec.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#include "JHybridOneNotificationsSpec.hpp"

// Forward declaration of `NativePermissionResponse` to properly resolve imports.
namespace margelo::nitro::one { struct NativePermissionResponse; }
// Forward declaration of `NotificationPermissionStatus` to properly resolve imports.
namespace margelo::nitro::one { enum class NotificationPermissionStatus; }
// Forward declaration of `NativeIosPermission` to properly resolve imports.
namespace margelo::nitro::one { struct NativeIosPermission; }
// Forward declaration of `NativeNotificationCategory` to properly resolve imports.
namespace margelo::nitro::one { struct NativeNotificationCategory; }
// Forward declaration of `NativeNotificationAction` to properly resolve imports.
namespace margelo::nitro::one { struct NativeNotificationAction; }
// Forward declaration of `NativeNotificationCategoryOptions` to properly resolve imports.
namespace margelo::nitro::one { struct NativeNotificationCategoryOptions; }
// Forward declaration of `NativeChannel` to properly resolve imports.
namespace margelo::nitro::one { struct NativeChannel; }
// Forward declaration of `NativeNotificationRequest` to properly resolve imports.
namespace margelo::nitro::one { struct NativeNotificationRequest; }
// Forward declaration of `NativeContent` to properly resolve imports.
namespace margelo::nitro::one { struct NativeContent; }
// Forward declaration of `NativeTrigger` to properly resolve imports.
namespace margelo::nitro::one { struct NativeTrigger; }
// Forward declaration of `NativeTriggerType` to properly resolve imports.
namespace margelo::nitro::one { enum class NativeTriggerType; }
// Forward declaration of `NativeNotification` to properly resolve imports.
namespace margelo::nitro::one { struct NativeNotification; }
// Forward declaration of `NativePushToken` to properly resolve imports.
namespace margelo::nitro::one { struct NativePushToken; }
// Forward declaration of `NativeNotificationResponse` to properly resolve imports.
namespace margelo::nitro::one { struct NativeNotificationResponse; }
// Forward declaration of `NativePermissionRequest` to properly resolve imports.
namespace margelo::nitro::one { struct NativePermissionRequest; }
// Forward declaration of `NativeIosPermissionRequest` to properly resolve imports.
namespace margelo::nitro::one { struct NativeIosPermissionRequest; }
// Forward declaration of `NativeChannelInput` to properly resolve imports.
namespace margelo::nitro::one { struct NativeChannelInput; }
// Forward declaration of `NativeScheduleInput` to properly resolve imports.
namespace margelo::nitro::one { struct NativeScheduleInput; }
// Forward declaration of `NativeContentInput` to properly resolve imports.
namespace margelo::nitro::one { struct NativeContentInput; }
// Forward declaration of `NativeTriggerInput` to properly resolve imports.
namespace margelo::nitro::one { struct NativeTriggerInput; }
// Forward declaration of `NotificationBehavior` to properly resolve imports.
namespace margelo::nitro::one { struct NotificationBehavior; }

#include "NativePermissionResponse.hpp"
#include <NitroModules/Promise.hpp>
#include <NitroModules/JPromise.hpp>
#include "JNativePermissionResponse.hpp"
#include "NotificationPermissionStatus.hpp"
#include "JNotificationPermissionStatus.hpp"
#include "NativeIosPermission.hpp"
#include <optional>
#include "JNativeIosPermission.hpp"
#include "NativeNotificationCategory.hpp"
#include "JNativeNotificationCategory.hpp"
#include <string>
#include "NativeNotificationAction.hpp"
#include <vector>
#include "JNativeNotificationAction.hpp"
#include "NativeNotificationCategoryOptions.hpp"
#include "JNativeNotificationCategoryOptions.hpp"
#include "NativeChannel.hpp"
#include "JNativeChannel.hpp"
#include <NitroModules/JUnit.hpp>
#include "NativeNotificationRequest.hpp"
#include "JNativeNotificationRequest.hpp"
#include "NativeContent.hpp"
#include "JNativeContent.hpp"
#include <NitroModules/AnyMap.hpp>
#include <NitroModules/JAnyMap.hpp>
#include "NativeTrigger.hpp"
#include "JNativeTrigger.hpp"
#include "NativeTriggerType.hpp"
#include "JNativeTriggerType.hpp"
#include "NativeNotification.hpp"
#include "JNativeNotification.hpp"
#include "NativePushToken.hpp"
#include "JNativePushToken.hpp"
#include "NativeNotificationResponse.hpp"
#include "JNativeNotificationResponse.hpp"
#include "NativePermissionRequest.hpp"
#include "JNativePermissionRequest.hpp"
#include "NativeIosPermissionRequest.hpp"
#include "JNativeIosPermissionRequest.hpp"
#include "NativeChannelInput.hpp"
#include "JNativeChannelInput.hpp"
#include "NativeScheduleInput.hpp"
#include "JNativeScheduleInput.hpp"
#include "NativeContentInput.hpp"
#include "JNativeContentInput.hpp"
#include "NativeTriggerInput.hpp"
#include "JNativeTriggerInput.hpp"
#include <functional>
#include "JFunc_void_std__string_NativeNotification.hpp"
#include <NitroModules/JNICallable.hpp>
#include "JFunc_void_NativeNotificationResponse.hpp"
#include "JFunc_void_NativePushToken.hpp"
#include "NotificationBehavior.hpp"
#include "JNotificationBehavior.hpp"

namespace margelo::nitro::one {

  std::shared_ptr<JHybridOneNotificationsSpec> JHybridOneNotificationsSpec::JavaPart::getJHybridOneNotificationsSpec() {
    auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
    auto castHybridObject = std::dynamic_pointer_cast<JHybridOneNotificationsSpec>(hybridObject);
    if (castHybridObject == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to downcast JHybridObject to JHybridOneNotificationsSpec!");
    }
    return castHybridObject;
  }

  jni::local_ref<JHybridOneNotificationsSpec::CxxPart::jhybriddata> JHybridOneNotificationsSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  std::shared_ptr<JHybridObject> JHybridOneNotificationsSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
    auto castJavaPart = jni::dynamic_ref_cast<JHybridOneNotificationsSpec::JavaPart>(javaPart);
    if (castJavaPart == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridOneNotificationsSpec::JavaPart!");
    }
    return std::make_shared<JHybridOneNotificationsSpec>(castJavaPart);
  }

  void JHybridOneNotificationsSpec::CxxPart::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridOneNotificationsSpec::CxxPart::initHybrid),
    });
  }

  // Properties
  

  // Methods
  std::shared_ptr<Promise<NativePermissionResponse>> JHybridOneNotificationsSpec::getPermissions() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getPermissions");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<NativePermissionResponse>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<JNativePermissionResponse>(__boxedResult);
        __promise->resolve(__result->toCpp());
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<NativePermissionResponse>> JHybridOneNotificationsSpec::requestPermissions(const NativePermissionRequest& options) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JNativePermissionRequest> /* options */)>("requestPermissions");
    auto __result = method(_javaPart, JNativePermissionRequest::fromCpp(options));
    return [&]() {
      auto __promise = Promise<NativePermissionResponse>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<JNativePermissionResponse>(__boxedResult);
        __promise->resolve(__result->toCpp());
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<double>> JHybridOneNotificationsSpec::getBadgeCount() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getBadgeCount");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<double>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JDouble>(__boxedResult);
        __promise->resolve(__result->value());
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<bool>> JHybridOneNotificationsSpec::setBadgeCount(double count) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(double /* count */)>("setBadgeCount");
    auto __result = method(_javaPart, count);
    return [&]() {
      auto __promise = Promise<bool>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
        __promise->resolve(static_cast<bool>(__result->value()));
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<NativeNotificationCategory>> JHybridOneNotificationsSpec::setNotificationCategory(const NativeNotificationCategory& category) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JNativeNotificationCategory> /* category */)>("setNotificationCategory");
    auto __result = method(_javaPart, JNativeNotificationCategory::fromCpp(category));
    return [&]() {
      auto __promise = Promise<NativeNotificationCategory>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<JNativeNotificationCategory>(__boxedResult);
        __promise->resolve(__result->toCpp());
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<std::vector<NativeNotificationCategory>>> JHybridOneNotificationsSpec::getNotificationCategories() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getNotificationCategories");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<std::vector<NativeNotificationCategory>>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JArrayClass<JNativeNotificationCategory>>(__boxedResult);
        __promise->resolve([&](auto&& __input) {
          size_t __size = __input->size();
          std::vector<NativeNotificationCategory> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = __input->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }(__result));
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<bool>> JHybridOneNotificationsSpec::deleteNotificationCategory(const std::string& identifier) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* identifier */)>("deleteNotificationCategory");
    auto __result = method(_javaPart, jni::make_jstring(identifier));
    return [&]() {
      auto __promise = Promise<bool>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
        __promise->resolve(static_cast<bool>(__result->value()));
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<std::optional<NativeChannel>>> JHybridOneNotificationsSpec::setNotificationChannel(const std::string& channelId, const NativeChannelInput& channel) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* channelId */, jni::alias_ref<JNativeChannelInput> /* channel */)>("setNotificationChannel");
    auto __result = method(_javaPart, jni::make_jstring(channelId), JNativeChannelInput::fromCpp(channel));
    return [&]() {
      auto __promise = Promise<std::optional<NativeChannel>>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<JNativeChannel>(__boxedResult);
        __promise->resolve(__result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt);
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<std::optional<NativeChannel>>> JHybridOneNotificationsSpec::getNotificationChannel(const std::string& channelId) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* channelId */)>("getNotificationChannel");
    auto __result = method(_javaPart, jni::make_jstring(channelId));
    return [&]() {
      auto __promise = Promise<std::optional<NativeChannel>>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<JNativeChannel>(__boxedResult);
        __promise->resolve(__result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt);
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<std::vector<NativeChannel>>> JHybridOneNotificationsSpec::getNotificationChannels() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getNotificationChannels");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<std::vector<NativeChannel>>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JArrayClass<JNativeChannel>>(__boxedResult);
        __promise->resolve([&](auto&& __input) {
          size_t __size = __input->size();
          std::vector<NativeChannel> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = __input->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }(__result));
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridOneNotificationsSpec::deleteNotificationChannel(const std::string& channelId) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* channelId */)>("deleteNotificationChannel");
    auto __result = method(_javaPart, jni::make_jstring(channelId));
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<std::string>> JHybridOneNotificationsSpec::scheduleNotification(const NativeScheduleInput& request) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JNativeScheduleInput> /* request */)>("scheduleNotification");
    auto __result = method(_javaPart, JNativeScheduleInput::fromCpp(request));
    return [&]() {
      auto __promise = Promise<std::string>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
        __promise->resolve(__result->toStdString());
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridOneNotificationsSpec::cancelScheduledNotification(const std::string& identifier) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* identifier */)>("cancelScheduledNotification");
    auto __result = method(_javaPart, jni::make_jstring(identifier));
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridOneNotificationsSpec::cancelAllScheduledNotifications() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("cancelAllScheduledNotifications");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<std::vector<NativeNotificationRequest>>> JHybridOneNotificationsSpec::getAllScheduledNotifications() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAllScheduledNotifications");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<std::vector<NativeNotificationRequest>>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JArrayClass<JNativeNotificationRequest>>(__boxedResult);
        __promise->resolve([&](auto&& __input) {
          size_t __size = __input->size();
          std::vector<NativeNotificationRequest> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = __input->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }(__result));
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<std::vector<NativeNotification>>> JHybridOneNotificationsSpec::getPresentedNotifications() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getPresentedNotifications");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<std::vector<NativeNotification>>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<jni::JArrayClass<JNativeNotification>>(__boxedResult);
        __promise->resolve([&](auto&& __input) {
          size_t __size = __input->size();
          std::vector<NativeNotification> __vector;
          __vector.reserve(__size);
          for (size_t __i = 0; __i < __size; __i++) {
            auto __element = __input->getElement(__i);
            __vector.push_back(__element->toCpp());
          }
          return __vector;
        }(__result));
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridOneNotificationsSpec::dismissNotification(const std::string& identifier) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* identifier */)>("dismissNotification");
    auto __result = method(_javaPart, jni::make_jstring(identifier));
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<void>> JHybridOneNotificationsSpec::dismissAllNotifications() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("dismissAllNotifications");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<void>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
        __promise->resolve();
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  std::shared_ptr<Promise<NativePushToken>> JHybridOneNotificationsSpec::getDevicePushToken() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getDevicePushToken");
    auto __result = method(_javaPart);
    return [&]() {
      auto __promise = Promise<NativePushToken>::create();
      __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
        auto __result = jni::static_ref_cast<JNativePushToken>(__boxedResult);
        __promise->resolve(__result->toCpp());
      });
      __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
        jni::JniException __jniError(__throwable);
        __promise->reject(std::make_exception_ptr(__jniError));
      });
      return __promise;
    }();
  }
  void JHybridOneNotificationsSpec::setListeners(const std::function<void(const std::string& /* requestId */, const NativeNotification& /* notification */)>& onReceived, const std::function<void(const NativeNotificationResponse& /* response */)>& onResponse, const std::function<void(const NativePushToken& /* token */)>& onPushToken) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string_NativeNotification::javaobject> /* onReceived */, jni::alias_ref<JFunc_void_NativeNotificationResponse::javaobject> /* onResponse */, jni::alias_ref<JFunc_void_NativePushToken::javaobject> /* onPushToken */)>("setListeners_cxx");
    method(_javaPart, JFunc_void_std__string_NativeNotification_cxx::fromCpp(onReceived), JFunc_void_NativeNotificationResponse_cxx::fromCpp(onResponse), JFunc_void_NativePushToken_cxx::fromCpp(onPushToken));
  }
  void JHybridOneNotificationsSpec::presentNotification(const std::string& requestId, const NotificationBehavior& behavior) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* requestId */, jni::alias_ref<JNotificationBehavior> /* behavior */)>("presentNotification");
    method(_javaPart, jni::make_jstring(requestId), JNotificationBehavior::fromCpp(behavior));
  }
  std::optional<NativeNotificationResponse> JHybridOneNotificationsSpec::getLastNotificationResponse() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JNativeNotificationResponse>()>("getLastNotificationResponse");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
  }
  void JHybridOneNotificationsSpec::clearLastNotificationResponse() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("clearLastNotificationResponse");
    method(_javaPart);
  }

} // namespace margelo::nitro::one
