Home › SDK for iOS and Android apps
SDK for iOS and Android apps
The same bot detection as on the web, for your apps. The SDK sends sessions, screens, installs and your own events, and our own algorithm shows whether a person or a fake phone is behind them.
Install (React Native / Expo)
Add your app in the dashboard with its bundle id (iOS) or package name (Android) and you get a key. Then install the package:
npm install https://t.optimizare-seo-google.ro/sdk/osg-analytics-latest.tgz # recommended, for better signals: npx expo install @react-native-async-storage/async-storage expo-device expo-battery expo-sensors
Usage
Initialise once, at startup. Wrap the root of your app in OsgRoot, so your app works with our own fake-phone detection algorithm.
import Osg, { OsgRoot } from 'osg-analytics';
Osg.init({ key: 'osg_...', app: 'com.example.app' }); // once, at startup
Osg.screen('Home'); // on each screen
Osg.track('purchase', { plan: 'pro' }); // custom events
Osg.setReferral('campaign-x'); // if you learn the referral later
export default function App() {
return <OsgRoot><YourApp /></OsgRoot>; // counts touches, never consumes them
}What we collect
- Sessions, screens, installs and the events you send.
- The model and OS version, screen size and language.
- Additional technical device signals, used by our own algorithm to detect fake phones.
- The IP network prefix (/24), not the full address. We do not collect advertising identifiers, contacts or location.
How we recognise fake phones
We use our own algorithm to detect a fake phone accessing the client's site or app. We do not make how it works public, so it stays effective.
Errors
Uncaught JS errors and unhandled promise rejections report themselves, chained onto any other handler (the development red box, another crash reporter) without replacing it. You can also report manually, from a try/catch or an error boundary:
Osg.init({ key: 'osg_...', app: 'com.example.app' }); // captureErrors: true by default
try {
risky();
} catch (err) {
Osg.captureError(err); // fatal defaults to false
}What we do with errors
We group by message and the first stack frame, so the same bug shows once in the dashboard, with a count and the steps before it (the last screens and events). Every error already comes labelled human or bot, so a real bug never hides in an emulator's noise.
What we do not do yet: we do not unminify stack traces with source maps and we do not catch native crashes (Obj-C, Kotlin), only JavaScript errors. A phone can send at most 20 errors a minute, and the same bug is reported at most 5 times per session, so an error loop never floods the app or the dashboard.
Referral
If you know where the install came from (Play Install Referrer, link parameters), pass it as referral at init or with setReferral. The first source stays on the device and rides on every event. On iOS, SKAdNetwork cannot be read on the device, so use the link parameters.
Attestation (Play Integrity, App Attest)
Optionally, give the SDK a function that returns the attestation token. We only report whether one existed, not the token. Verifying it on the server is not active yet, so it does not affect the score.
Native apps (Swift / Kotlin): the HTTP protocol
Without React Native, send the same JSON directly. The collector always answers 204 and needs no special headers.
POST https://t.optimizare-seo-google.ro/c
Content-Type: text/plain
{
"k": "osg_...", // app key from the dashboard
"app": "com.example.app", // bundle id / package name, exactly as registered
"src": "ios", // "ios" or "android"
"v": "installation-id", // random id kept on the device
"s": "session-id", // new after 30 minutes in the background
"sig": { "os": "ios 18.1", "model": "iPhone15,2", "emu": false, "chg": false,
"still": false, "face": "up", "sw_": 393, "sh_": 852, "tc": 12, "lg": 1, "sdk": "native-1" },
"ev": [ { "t": "session" }, { "t": "install", "ref": "campaign-x" },
{ "t": "screen", "u": "Home" }, { "t": "event", "d": { "name": "purchase" } } ]
}
-> 204 No Content (always)
Check your app for free
Add your app, install the SDK and see who really uses it: people or bots.
Get started free