react-native-appmetrica/README.md

57 lines
1.5 KiB
Markdown
Raw Normal View History

2021-01-21 07:29:24 +03:00
# react-native-appmetrica-next
2020-06-08 22:14:06 +03:00
React Native bridge to the [AppMetrica](https://appmetrica.yandex.com/) on both iOS and Android.
2021-01-21 07:29:24 +03:00
react-native-push-next library functionality is expanded [react-native-appmetrica](https://github.com/yandexmobile/react-native-appmetrica)
2020-06-08 22:14:06 +03:00
## Installation
2021-01-21 07:29:24 +03:00
`npm install react-native-appmetrica-next --save`
or
`yearn add react-native-appmetrica-next`
2020-06-08 22:14:06 +03:00
## Usage
```js
2021-01-21 07:29:24 +03:00
import AppMetrica from "react-native-appmetrica-next";
2020-06-08 22:14:06 +03:00
// Starts the statistics collection process.
2020-12-22 15:03:52 +03:00
AppMetrica.activate({
2021-01-21 07:29:24 +03:00
apiKey: "...KEY...",
2020-06-08 22:14:06 +03:00
sessionTimeout: 120,
firstActivationAsUpdate: true,
});
// Sends a custom event message and additional parameters (optional).
2021-01-21 07:29:24 +03:00
AppMetrica.reportEvent("My event");
AppMetrica.reportEvent("My event", { foo: "bar" });
2020-06-08 22:14:06 +03:00
// Send a custom error event.
2021-01-21 07:29:24 +03:00
AppMetrica.reportError("My error");
2021-01-21 14:00:35 +03:00
// reportUserProfile
AppMetrica.activate({
apiKey: "...KEY...",
sessionTimeout: 120,
firstActivationAsUpdate: true,
});
RNAppMetrica.setUserProfileID('id');
RNAppMetrica.reportUserProfile({
name: 'Andrey Bondarenko',
floor: 'male',
age: 34,
isNotification: true,
});
// init Push SDK example for iOS
checkPermission = async () => {
const authorizationStatus = await messaging().requestPermission();
if (authorizationStatus === messaging.AuthorizationStatus.AUTHORIZED) {
const deviceToken = await messaging().getToken();
RNAppMetrica.initPush(deviceToken); -> // for iOS
// or
RNAppMetrica.initPush(); -> // for Android
2020-06-08 22:14:06 +03:00
```