diff --git a/android/build.gradle b/android/build.gradle index 4fd1d5b..17c4759 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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' } diff --git a/android/src/main/java/com/yandex/metrica/plugin/reactnative/AppMetricaModule.java b/android/src/main/java/com/yandex/metrica/plugin/reactnative/AppMetricaModule.java index bb00f2b..634a1d2 100644 --- a/android/src/main/java/com/yandex/metrica/plugin/reactnative/AppMetricaModule.java +++ b/android/src/main/java/com/yandex/metrica/plugin/reactnative/AppMetricaModule.java @@ -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)); diff --git a/index.js b/index.js index eeaf7c0..7ed5dbb 100644 --- a/index.js +++ b/index.js @@ -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); }, diff --git a/package.json b/package.json index a836b25..3bcba85 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/react-native-appmetrica-next.podspec b/react-native-appmetrica-next.podspec index 7216fb5..ff33406 100644 --- a/react-native-appmetrica-next.podspec +++ b/react-native-appmetrica-next.podspec @@ -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