gpt4 book ai didi

android - 从 JavaScript,触发 native 代码功能

转载 作者:行者123 更新时间:2023-11-29 14:08:24 24 4
gpt4 key购买 nike

我有一个使用 Localytics 服务的 PhoneGap 应用程序,我想跟踪某个事件,因此我想在某个时刻从 Javascript 代码调用带有几个参数的 native 函数。然后,此 native 函数将调用 Localytics 的事件跟踪函数,如下所示:

NSDictionary *dictionary =
[NSDictionary dictionaryWithObjectsAndKeys:
@"miles per hour",
@"display units",
@"yes",
@"blank screen",
nil];
[[LocalyticsSession sharedLocalyticsSession] tagEvent:@"Options saved" attributes:dictionary];

有JS调用原生代码并传递参数的例子吗?

谢谢!

最佳答案

https://github.com/purplecabbage/phonegap-plugins 的 Phonegap 插件中有一堆 JavaScript -> Java 调用的例子。

关于android - 从 JavaScript,触发 native 代码功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5268902/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com