简体   繁体   English

KISSmetrics - React Native iOS

[英]KISSmetrics - React Native iOS

I am using React native to create an iOS app;我正在使用 React Native 创建一个 iOS 应用程序; So my code is in javascript and some objective-c.所以我的代码是在javascript和一些objective-c中。

Now i wan't to implement KISSmetrics in my project, i have done the proper setup based on kissmetrics documentation , but when it comes to create events and user identifications etc… i have to use data from my javascript code.现在我不想在我的项目中实现 KISSmetrics,我已经根据Kissmetrics 文档进行了正确的设置,但是当涉及到创建事件和用户标识等时……我必须使用我的 javascript 代码中的数据。

Does anyone knows how to do that?有谁知道怎么做? for example: the objective-c code to identify the user is this: [[KISSmetricsAPI sharedAPI] identify:@"name@email.com"];例如:识别用户的objective-c代码是这样的: [[KISSmetricsAPI sharedAPI] identify:@"name@email.com"]; but how can i get the code that gets the identity of the user and replace the name@email.com from my javascript code?但是我怎样才能获得获取用户身份的代码并从我的 javascript 代码中替换name@email.com呢?

I would look here to find out how to build a native module bridge.我会在这里查看如何构建本机模块桥。 The way it works is that you create an iOS native module with methods that you can actually call from JavaScript by which you can send your data from JS to Obj-C.它的工作方式是您创建一个 iOS 原生模块,其中包含您可以从 JavaScript 实际调用的方法,通过这些方法您可以将数据从 JS 发送到 Obj-C。

Here's an example project that does this: https://github.com/idehub/react-native-google-analytics-bridge这是一个执行此操作的示例项目: https : //github.com/idehub/react-native-google-analytics-bridge

You don't need to turn it into a full-fledged NPM library, you can just simply create the necessary native files and JS files on the fly in your project.你不需要把它变成一个成熟的 NPM 库,你可以简单地在你的项目中动态创建必要的本机文件和 JS 文件。

Also, if you don't know already, remember to rebuild the iOS project (hit the Play button) to see your changes because the native side doesn't have Live Reloading.此外,如果您还不知道,请记住重建 iOS 项目(点击播放按钮)以查看您的更改,因为本机端没有实时重新加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM