Search code examples
javascriptiosobjective-creact-nativekissmetrics

KISSmetrics - React Native iOS


I am using React native to create an iOS app; So my code is in javascript and some 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.

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"]; but how can i get the code that gets the identity of the user and replace the name@email.com from my javascript code?


Solution

  • 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.

    Here's an example project that does this: 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.

    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.