1.0.16 • Published 11 months ago

react-native-react-native-settings v1.0.16

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

react-native-react-native-settings

Getting started

$ npm install react-native-react-native-settings --save $ yarn add react-native-react-native-settings

Android

Se usar expo, lembre de baixar um apk de desenvolvimento que use o npx expo start --dev-client. (Modulos nativos tais como esse, precisa ser rebuildado para funcionar no expo.)

Usage, Version >= 1.0.14 or version more attualized

import { useEffect } from "react";
import { DeviceEventEmitter } from "react-native";
import ReactNativeSettings from "react-native-react-native-settings";

    useEffect(() => {
      const volumeChangeListener = DeviceEventEmitter.addListener(
        "VolumeChange",
        (data) => {
          if (AppState.currentState === "active") {
            console.log("Volume mudou para", data?.currentVolume);
          }
        }
      );

      const listenerNetwork = DeviceEventEmitter.addListener(
          "NetworkChange",
          (data) => {
            console.log("internet: ", data);
          }
        );

      return () => {
        volumeChangeListener.remove();
        listenerNetwork.remove();
      };
    }, []);

Usage, Version < 1.0.13

import { useEffect } from "react";
import { DeviceEventEmitter } from "react-native";
import RNReactNativeSettings from "react-native-react-native-settings";


  useEffect(() => {
      // Voce precisa chamar o startListeningVolumeChanges() para começar a monitorar o volume
        RNReactNativeSettings.startListeningVolumeChanges();
        const listenerVolume = DeviceEventEmitter.addListener(
          "VolumeChange",
          (data) => {
            console.log("Volume mudou para", data.currentVolume);
          }
        );

      // Voce precisa chamar o startListeningNetworkChanges() para começar a monitorar a internet
        RNReactNativeSettings.startListeningNetworkChanges();
        const listenerNetwork = DeviceEventEmitter.addListener(
          "NetworkChange",
          (data) => {
            console.log("internet: ", data);
          }
        );

        return () => {
          listenerNetwork.remove();
          listenerVolume.remove();
        };
  }, []);
// TODO: What to do with the module?
RNReactNativeSettings;
1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago