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-newestapps-push

v0.1.6

Published

Push Notifications handling made simple

Downloads

7

Readme

react-native-newestapps-push

Getting Started

This package configures and handle in app settings for the device. So every time your application in installed in another device, it will generate unique ids and props for that device. All settings should be stored in user's account in the server, so you can use push notifications from server side with ease.

Also, this package is a MUST when using Newestapps-OfflineFirst structure, because it configure UUID for device, and proper sync times for every push and pull routines, that your app will run.

Requirements

  • @react-native-firebase/app - Properly installed and setup for usage
  • @react-native-firebase/messaging - Installed and linked in your app
  • @react-native-community/async-storage - Installed and linked in your app
  • react-native-uuid - Installed and linked in your app

Install all of them:

npm install @react-native-community/async-storage react-native-uuid @react-native-firebase/messaging --save

And run link when necessary:

npx react-native link @react-native-community/async-storage
npx react-native link @react-native-firebase/app
npx react-native link @react-native-firebase/messaging

Installation

Run npm install

npm install react-native-newestapps-push --save

*Note: you must have access to newestapps organization in Github, and SSH key configured in your own Github account.

Usage

You must encapsulate your "device" related features, in the PushProvider provided by this package.. See the example below

import { PushProvider } from 'react-native-newestapps-push';

export default function MyApp() => {

	return (
		<>

			<PushProvider>

				{/** My app components and children, here! */}

			</PushProvider>

		</>
	)
}

And in your children components, you can access the device information, using the hook useDevice

import { useDevice } from 'react-native-newestapps-push'

// ...

const [deviceUuid, devicePushToken] = useDevice();

// ...

In most cases, setting the provider in the right place, should work fine.. You only need device information, when syncing to the server, to provide a configuration for push notifications, and device Sync (if using a Newestapps-OfflineFirst structure)

Receiving Remote Messages from FCM

An event is emitted through DeviceEventEmitter, with key @Newestapps:Push:REMOTE_MESSAGE, all listeners added to your components that watch this event, will receve a remoteMessage (FOREGROUND ONLY)

Alternatively, we provide a component based alternative for this event watchers. See below:

import { MessageListener, RemoteMessage } from 'react-native-newestapps-push'

export default function DoSomethingAmazingWithPush() => {
	return (
		<>
			{/** ... My component code*/}

			<MessageListener
				onMessage={(remoteMessage: RemoteMessage) => {
					console.log('Just received this: ', remoteMessage);
				}}
			/>
		</>
	)
}