add pushSDK for Android

This commit is contained in:
Andrey Bondarenko 2021-01-21 16:18:28 +10:00
parent c54ba7d4d2
commit 35dda6dbdf
5 changed files with 22 additions and 3 deletions

View File

@ -82,6 +82,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.yandex.android:mobmetricalib:3.18.0'
implementation "com.yandex.android:mobmetricapushlib:1.10.0"
implementation 'com.android.installreferrer:installreferrer:1.1.2'
}

View File

@ -18,6 +18,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.yandex.metrica.YandexMetrica;
import com.yandex.metrica.push.YandexMetricaPush;
public class AppMetricaModule extends ReactContextBaseJavaModule {
@ -50,6 +51,11 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void initPush() {
YandexMetricaPush.init(reactContext);
}
@ReactMethod
public void reportUserProfile(ReadableMap configAttributes) {
YandexMetrica.reportUserProfile(Utils.toYandexProfileConfig(configAttributes));

View File

@ -6,7 +6,7 @@
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/
import {NativeModules} from 'react-native';
import {NativeModules, Platform} from 'react-native';
const {AppMetrica} = NativeModules;
@ -62,6 +62,14 @@ export default {
AppMetrica.activate(config);
},
initPush(token = ''){
if(Platform.OS === 'android') {
AppMetrica.initPush();
} else {
AppMetrica.initPush(token);
}
}
reportUserProfile(config: UserProfileConfig){
AppMetrica.reportUserProfile(config);
},

View File

@ -1,7 +1,7 @@
{
"name": "react-native-appmetrica-next",
"title": "Yandex AppMetrica React Native Plugin",
"version": "1.0.2",
"title": "Yandex AppMetrica React Native Plugin && AppMetricaPushSDK (fireBase CloudMessage)",
"version": "1.0.3",
"description": "React Native plugin for AppMetrica analytics tool",
"main": "index.js",
"scripts": {
@ -15,6 +15,9 @@
"yandex",
"appmetrica",
"metrica",
"pushSDK",
"push",
"sdk",
"analytics",
"tracking",
"react-native",

View File

@ -17,4 +17,5 @@ Pod::Spec.new do |s|
s.dependency "React"
s.dependency 'YandexMobileMetrica', '3.12.0'
s.dependency 'YandexMobileMetricaPush', '0.8.0'
end