npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-appmetrica-next

v2.8.3

Published

React Native plugin for AppMetrica analytics tool

Downloads

82

Readme

react-native-appmetrica-next

WARNING!!! ver 2.0 RN68 >= ver 1.0.17 RN67 <=

React Native bridge to the AppMetrica on both iOS and Android. react-native-push-next library functionality is expanded react-native-appmetrica

Installation

npm install react-native-appmetrica-next --save or yearn add react-native-appmetrica-next

Usage

import AppMetrica from "react-native-appmetrica-next";

// Starts the statistics collection process.
AppMetrica.activate({
  apiKey: "...KEY...",
  sessionTimeout: 120,
  firstActivationAsUpdate: true,
});

// Sends a custom event message and additional parameters (optional).
AppMetrica.reportEvent("My event");
AppMetrica.reportEvent("My event", { foo: "bar" });

// Send a custom error event.
AppMetrica.reportError("My error");

// reportUserProfile
AppMetrica.activate({
  apiKey: "...KEY...",
  sessionTimeout: 120,
  firstActivationAsUpdate: true,
});
RNAppMetrica.setUserProfileID("id");
RNAppMetrica.reportUserProfile({
  name: "Andrey Bondarenko",
  floor: "male",
  age: 34,
  isNotification: true,
});

SETTING PUSH SDK

NEXT for Android

create file FirebaseMessagingMasterService.java in you project

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.yandex.metrica.push.firebase.MetricaMessagingService;

public class FirebaseMessagingMasterService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage message) {
super.onMessageReceived(message);
// AppMetrica automatically recognizes its messages and processes them only.
new MetricaMessagingService().processPush(this, message);

        // Implement the logic for sending messages to other SDKs.
    }

}

Your files to Android manifest

<application>
  ...
  <service
    android:name=".FirebaseMessagingMasterService"
    android:enabled="true"
    android:exported="false"
  >
    <intent-filter android:priority="100">
      <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
  </service>
  <service
    android:name="com.yandex.metrica.push.firebase.MetricaMessagingService"
    tools:node="remove"
  />
  ...
</application>

Silent Push Notifications for Android

create file BroadcastReceiver in you project

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.yandex.metrica.push.YandexMetricaPush;


public class SilentPushReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving
        // an Intent broadcast.
        String payload = intent.getStringExtra(YandexMetricaPush.EXTRA_PAYLOAD);

        throw new UnsupportedOperationException("Not yet implemented");
    }
}

Your files to Android manifest

<application>
  ...
 <receiver android:name=".SilentPushReceiver">
            <intent-filter>
                <!-- Receive silent push notifications. -->
                <action android:name="${applicationId}.action.ymp.SILENT_PUSH_RECEIVE"/>
            </intent-filter>
        </receiver>

NEXT for iOS

file AppDelegate.m add

// Add import
#import <YandexMobileMetricaPush/YMPYandexMetricaPush.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  ...
  // Enable in-app push notifications handling in iOS 10
      if ([UNUserNotificationCenter class] != nil) {
          id<YMPUserNotificationCenterDelegate> delegate = [YMPYandexMetricaPush userNotificationCenterDelegate];
          delegate.nextDelegate = [UNUserNotificationCenter currentNotificationCenter].delegate;
          [UNUserNotificationCenter currentNotificationCenter].delegate = delegate;
      }

    [YMPYandexMetricaPush handleApplicationDidFinishLaunchingWithOptions:launchOptions];
...
...
}

// and ADD
- (void)application:(UIApplication *)application
    didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    [YMPYandexMetricaPush handleRemoteNotification:userInfo];
}
- (void)application:(UIApplication *)application
    didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    [YMPYandexMetricaPush handleRemoteNotification:userInfo];
}

...
...
@end

Usage (FIREBASE CLOUD MESSAGE)

import AppMetrica from "react-native-appmetrica-next";

// 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();