mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
feat(cast): clicking on the notif opens specified path
This commit is contained in:
+7
-3
@@ -34,8 +34,11 @@ namespace margelo::nitro::omni {
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto fieldReceiverApplicationId = clazz->getField<jni::JString>("receiverApplicationId");
|
||||
jni::local_ref<jni::JString> receiverApplicationId = this->getFieldValue(fieldReceiverApplicationId);
|
||||
static const auto fieldNotificationUrl = clazz->getField<jni::JString>("notificationUrl");
|
||||
jni::local_ref<jni::JString> notificationUrl = this->getFieldValue(fieldNotificationUrl);
|
||||
return CastOptions(
|
||||
receiverApplicationId != nullptr ? std::make_optional(receiverApplicationId->toStdString()) : std::nullopt
|
||||
receiverApplicationId != nullptr ? std::make_optional(receiverApplicationId->toStdString()) : std::nullopt,
|
||||
notificationUrl != nullptr ? std::make_optional(notificationUrl->toStdString()) : std::nullopt
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,12 +48,13 @@ namespace margelo::nitro::omni {
|
||||
*/
|
||||
[[maybe_unused]]
|
||||
static jni::local_ref<JCastOptions::javaobject> fromCpp(const CastOptions& value) {
|
||||
using JSignature = JCastOptions(jni::alias_ref<jni::JString>);
|
||||
using JSignature = JCastOptions(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
|
||||
static const auto clazz = javaClassStatic();
|
||||
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
||||
return create(
|
||||
clazz,
|
||||
value.receiverApplicationId.has_value() ? jni::make_jstring(value.receiverApplicationId.value()) : nullptr
|
||||
value.receiverApplicationId.has_value() ? jni::make_jstring(value.receiverApplicationId.value()) : nullptr,
|
||||
value.notificationUrl.has_value() ? jni::make_jstring(value.notificationUrl.value()) : nullptr
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,7 +20,10 @@ import java.util.Objects
|
||||
data class CastOptions(
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val receiverApplicationId: String?
|
||||
val receiverApplicationId: String?,
|
||||
@DoNotStrip
|
||||
@Keep
|
||||
val notificationUrl: String?
|
||||
) {
|
||||
/* primary constructor */
|
||||
|
||||
@@ -28,11 +31,13 @@ data class CastOptions(
|
||||
if (this === other) return true
|
||||
if (other !is CastOptions) return false
|
||||
return Objects.deepEquals(this.receiverApplicationId, other.receiverApplicationId)
|
||||
&& Objects.deepEquals(this.notificationUrl, other.notificationUrl)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return arrayOf<Any?>(
|
||||
receiverApplicationId
|
||||
receiverApplicationId,
|
||||
notificationUrl
|
||||
).contentDeepHashCode()
|
||||
}
|
||||
|
||||
@@ -44,8 +49,8 @@ data class CastOptions(
|
||||
@Keep
|
||||
@Suppress("unused")
|
||||
@JvmStatic
|
||||
private fun fromCpp(receiverApplicationId: String?): CastOptions {
|
||||
return CastOptions(receiverApplicationId)
|
||||
private fun fromCpp(receiverApplicationId: String?, notificationUrl: String?): CastOptions {
|
||||
return CastOptions(receiverApplicationId, notificationUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -41,10 +41,11 @@ namespace margelo::nitro::omni {
|
||||
struct CastOptions final {
|
||||
public:
|
||||
std::optional<std::string> receiverApplicationId SWIFT_PRIVATE;
|
||||
std::optional<std::string> notificationUrl SWIFT_PRIVATE;
|
||||
|
||||
public:
|
||||
CastOptions() = default;
|
||||
explicit CastOptions(std::optional<std::string> receiverApplicationId): receiverApplicationId(receiverApplicationId) {}
|
||||
explicit CastOptions(std::optional<std::string> receiverApplicationId, std::optional<std::string> notificationUrl): receiverApplicationId(receiverApplicationId), notificationUrl(notificationUrl) {}
|
||||
|
||||
public:
|
||||
friend bool operator==(const CastOptions& lhs, const CastOptions& rhs) = default;
|
||||
@@ -60,12 +61,14 @@ namespace margelo::nitro {
|
||||
static inline margelo::nitro::omni::CastOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
||||
jsi::Object obj = arg.asObject(runtime);
|
||||
return margelo::nitro::omni::CastOptions(
|
||||
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiverApplicationId")))
|
||||
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiverApplicationId"))),
|
||||
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "notificationUrl")))
|
||||
);
|
||||
}
|
||||
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::CastOptions& arg) {
|
||||
jsi::Object obj(runtime);
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "receiverApplicationId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.receiverApplicationId));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "notificationUrl"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.notificationUrl));
|
||||
return obj;
|
||||
}
|
||||
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
||||
@@ -77,6 +80,7 @@ namespace margelo::nitro {
|
||||
return false;
|
||||
}
|
||||
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiverApplicationId")))) return false;
|
||||
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "notificationUrl")))) return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user