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

@stryberventures/stryber-rn-core-components-push-notifications-service

v0.0.2

Published

## Description ##

Downloads

3

Readme

Stryber React Native Push Notifications Service

Description

Service which has common API to work with Firebase Cloud Messages and local push notifications on Android and iOS. By default, FCM SDK shows Push Notifications which appeared when application was in background mode or in quit state. However, FCM SDK provides application with callback function, which tells that notification was received. It means if we want to show PNs when application is in foreground (active), we should create them locally when callback from FCM SDK was called.

This version of PushNotificationService shows PNs in all application states.

Installation

This module requires that the @react-native-firebase/app module is already setup and installed. To install the "app" module, view the Getting Started documentation.

Install dependencies

npm i @stryberventures/[email protected] @react-native-community/[email protected] @react-native-firebase/[email protected] [email protected] --save

Next steps are required only for iOS

Install pods

cd ios/ && pod install

Go through iOS installation guide, it describes how to:

  1. Enable push notifications in xcode.
  2. Enable background processes in xcode.
  3. How to create Push notification certificate and link it in Firebase console.

Navigate to ios/yourprojectname/AppDelegate.h

  • add import
#import <UserNotifications/UNUserNotificationCenter.h>
  • pass imported interface to UIResponder
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

Navigate to ios/yourprojectname/AppDelegate.m

  • add import
#import <UserNotifications/UserNotifications.h>
#import <RNCPushNotificationIOS.h>
  • add next code before return of didFinishLaunchingWithOptions
  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;
  • add next code in the AppDelegate implementation (before @end)
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
 [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
 [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)(void))completionHandler
{
  [RNCPushNotificationIOS didReceiveNotificationResponse:response];
}

//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
  completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
}

Installation guides and troubleshooting:

RN wrapper for Firebase SDK

React Native Push Notifications

React Native Push Notifications iOS

Known issues

  • messaging().getInitialNotification() on Android payload is empty
  • Firebase console doesn't show if local notification was opened