So I have a completed React Native project for iOS but I want to put analytics in it. I tried the react-native-google-analytics package, but issues prevent it from working properly. Also, the react-native-cordova-plugin package is only working on Android, so the ability to plug in a Cordova plugin for analytics is out of the question for now. I also do not have Swift / objective C experience, so would be completely lost pluggin in GA that way. Does anyone have any suggestions on how to hook up Google Analytics (or any other analytics) for React Native for iOS? If so, please give some detailed instructions on doing so. I, and I'm sure, many others will appreciate it :)
I am the author of a Google Analytics package for React Native: https://github.com/idehub/react-native-google-analytics-bridge
Since it is a pretty simple native bridge to the official Google Analytics libraries, it should not give you any issues related to the platform. Also, it will handle a lot of the metadata automatically, like the device UUID, device model, viewport size, OS version etc.
Because of that last part, the calls can be pretty simple, like tracking a new screen view:
import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge';
let tracker = new GoogleAnalyticsTracker('UA-12345-1');
tracker.trackScreenView('Home')
Or an event:
tracker.trackEvent('testcategory', 'testaction');
I'm the author of react-native-google-analytics -- the problem with it has been with React Native's lack of support for GIF data in XHR responses on iOS 7. I'm still trying to figure out if the problem people are experiencing is still limited to iOS 7. The bug was reported as fixed by the RN team for iOS > 7, however if that is not the case then there must be a regression. Tracking for the React Native issue is here: https://github.com/facebook/react-native/issues/1780
If you have any other questions regarding the module specifically, please don't hesitate to ask on GitHub!
I just set up mixpanel with this package:
https://github.com/davodesign84/react-native-mixpanel
And then I have something like this in my main.js file that holds all my view components:
componentWillMount: function() {
this.loadData(this.setDataState);
// not sure if this is the best way to do it, but whatever
Mixpanel.identify(DeviceInfo.getUniqueID());
Mixpanel.set("$name", DeviceInfo.getDeviceName());
Mixpanel.track("App Loaded");
}
And then in my view.js that renders a component with data, I have something like this:
componentWillMount: function() {
Mixpanel.trackWithProperties("Definition Viewed",{word:this.state.word});
}
And then I also call mixpanel when a users adds/deletes data.
After all this, I just noticed that fabric does analytics so I will probably migrate to that because I use to to manage beta testers and its awesome so it'll be nice to have everything in 1 place
So this may be helpful to people, but I found Segment - https://segment.com/ - a lot easier to get setup. Segment has integration with Google Analytics and all the other analytics packages, so it easy once the connection is made. I had to follow some tutorials on creating a native bridge using the RCT_EXPORT_MODULE technique, but once I established a connection to the client, I was able to pretty much plug in the Segment starter code. I linked specific event calls to different actions on the client side through NativeModules.AnalyticsHelper.openApp(clientId), NativeModules.AnalyticsHelper.shareContent(clientId), etc.. I think this is a good method to follow.
I also created a gist to show how to setup Segment Analytics for React native.
Related
I really want to make use of the pencil kit in my react-native application. I just want to know whether I can do it. If yes, then how?
TLDR: Doesn't exist as of 2/6/2021 and you will need to write bridge code between react native (js) and native (swift/ObjC). There are big performance limitations with this approach. I recommend you create a native Swift based app for your project.
I was also curious if this is available.
For those willing to use Swift, here's the sample shown during the demo.
For those that want to use PencilKit / CoreML native libraries from React native you need need to write bridge code between Javascript (please use typescript) and the native code.
Here's more information on bridging and a guide.
For me, I will be building a note taking app and it needs to be performant. Despite being a react / react native developer I will be choosing Swift to build this project due to performance concerns.
Last point to make is that you can use react native and native together. But this is more of a headache than an enabler. AirBnB used this for some time but moved away from this approach.
For anyone new to React Native, it's a great platform. I personally like to use it for simple applications (not graphically intensive). You can also use it with the Expo tooling which speeds up prototyping but be warned some functionalities are not available bluetooth is one example.
Yes I Did it.
I created a native view for iOS Pencil Kit in React Native with Swift.
You can check basic examples for native module in my Repo
you probably know, GVRSDK is deprecated and it includes UIWebview reference which is problematic because iOS is removing UIWebView. Currently submitted applications receive a warning, but eventually will be auto-rejected.
That's why I try to implement the new google cardboard:
https://developers.google.com/cardboard/develop/ios/quickstart
Problem is there is no carthage, no pod.
Did you try to use this sdk in you own project ?
I am trying but unsuccessfully :( The documents is rather useless ...
Do you have a simple idea how to use this SDK? Maybe I miss something ?
Thanks
EDIT: this question is outdated - TwitterKit is now available via CocoaPods
It seems to involve downloading an application, giving that application the path to my project, and adding one of their executables as a build phase.
It seems like that requires placing a lot of trust in Fabric...
Is there a good reason they're not providing the option to download TwitterKit in a more standard way, like a framework or a cocoapod?
Great question, the short answer is that we built the application to reduce friction when implementing any of the kits (TwitterKit, Crashlytics and MoPub).
Longer answer - there are various reasons for the Fabric application vs a "native" implementation. Currently the Fabric application provides a bunch of functionality that reduced friction for folks trying to implement any of the kits (i.e. Crashlytics, Twitter and MoPub). On the Crashlytics side we do a variety of things like take the dsym to replace the symbols in the crash logs with the appropriate methods names so crash reports are readable (also this makes it v.easy to provide a linkage between accounts, without the need for a key variable in the code). On the TwitterKit side it's fairly similar story, rather than take measures to get your keys/secrets from apps.twitter.com you can simply use the application that does some heavy lifting.
You can rest assured that the team isn't trying to do anything shady here. Feel free to reply here if you have any questions :-)
You are also free to download Twitter Kit as a CocoaPod: https://cocoapods.org/pods/TwitterKit
Just add the following to your Podfile:
pod 'TwitterKit`
Is it possible to create an iOS library or framework using libgdx (RoboVM) that can be imported into Xcode?
Background:
One of my colleagues has created a 3D visualisation app as a libgdx project for android and windows desktop. It can be compiled to run on iOS using RoboVM. However, I would like to wrap extra native user interface elements around it using Xcode. I know its possible to build the user interface programmatically via RoboVM but I would be keen to investigate if its possible to bring the existing work into Xcode. I don't need to edit the 3D visualisation component but add extra GUI elements around the 3D Vis window. I thought compiling the libgdx (RoboVM) code to a framework or library might be a solution that could be imported?!
Yes you can do it.
All you need to create a method, say initRoboVM(), This will be called by your code when you want to initialize libgdx. You'll need to pass the app path in, which you can hardcode when you're testing.
initRoboVM() will need some modifications, namely it should not call your Java app's main method, well, at least, that's what well behaving libraries should not do IMO. It should also not call rvmShutdown.
You can get further information from here
Thanks :)
I asked the RoboVM team directly. Their answer: It's not a native function, but it certainly can be done.
The complete message...
Hi,
Sorry for the late reply. This use case is not something we're going
to do now. It is possible though if you're prepared to do some
patching of RoboVM. Search the RoboVM Google Group and you should find
others who have managed to get this working.
We get this request every know and then so we will add support for
this eventually.
Regards, Niklas
i'm trying to create an app which uses the combination of native functionality and the phoneGap framework. The native app has a button, upon the click of which the phoneGap ui has to be added to the view. Is there any way to achieve this? Are there any tutorials for the same?
Yes, this is possible. Although you might be getting yourself into some headaches. My app kind of goes the other way around, it's mostly phonegap, but occasionally i'll pop open a view that is native. Here is the link to code that shows an excellent example of how to switch between the iOS and phonegap worlds.
new updated recommended article (see update below)
These files represent a standard plugin used in phonegap. In this particular plugin, a native view is opened on top of a phonegap view. Notice you have a custom xib and everything. This plugin can be modified to display any xib with any functionality you could think of.
If you implement this plugin you will easily see how to jump back and forth. I've successfully heavily modified these classes to add LOTS of native capabilities to my phonegap project. Also you should probably check out the official phonegap guide to phonegap plugins. Here
Important Edit
Was informed original linkwas broken (not terribly surprised as this answer is very old and i've long since moved away from Phonegap) so I replaced the original link with an article that shows how to do these plugins well. In the article it explains the link is broken and gives several links where these older files are maintained, but in fact those are broken as well. Here is a branch of one of them I found that still hosts the original files on an "archive" branch. But I haven't investigated whether these files are wildly different from my original work. Good luck!
That's not how Phonegap is meant to be used.
To achieve what you are asking for you just need to create a Phonegap app and add the extra native functionality by writing a Phonegap plugin in Objective-C. You may add as much native code as you want.
I'm actually wanting to do the same thing as the original poster. Theoretically it would be comparatively easy, but non-trival to do. I'd love it if there was a PhoneGapView that one could integrate into an existing project. Bonus points if said PhoneGapView could be integrated in Interface Builder as a re-sizeable and re-positional object, basically think of it as an Object that extends UIWebView.
This is wishful thinking on my part seeing as this is how the higher-ups want my project.