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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-ios-app-groups

v1.0.0

Published

Fetch app group path from ios so you can access them in react native

Readme

react-native-ios-app-groups

A React Native module to interact with iOS App Groups, enabling shared storage access between your main app and app extensions (like notification services).

Why This Package?

I created this package while building an iOS app that needed to maintain consistent badge counts between the main app and its notification service extension. The main challenge was accessing shared storage (App Groups) from both React Native and native iOS code. This package provides a clean interface to:

  1. Access App Group container URLs from React Native
  2. Manage badge counts in a way that's accessible to both the main app and notification service extensions
  3. Maintain state consistency across app components using shared storage

Installation

npm install react-native-ios-app-groups

iOS Setup

  1. Enable App Groups in your Xcode project:
    • Select your target
    • Go to "Signing & Capabilities"
    • Click "+" and add "App Groups"
    • Add your app group identifier (e.g., "group.com.your.app")
    • Repeat this process for your notification service extension if you have one

Usage

import { getContainerURL, setBadgeCount } from 'react-native-ios-app-groups';

// Get the container URL for your app group
try {
  const url = await getContainerURL('group.com.your.app');
  console.log('Container URL:', url);
} catch (error) {
  console.error('Error:', error);
}

// Set badge count in app group container
try {
  await setBadgeCount('group.com.your.app', 5);
  console.log('Badge count set successfully');
} catch (error) {
  console.error('Error setting badge count:', error);
}

Badge Count Storage

The setBadgeCount method stores the badge count in a specific location within your app group container: RCTAsyncLocalStorage/badge_count. This location is deliberately chosen to be easily accessible from your notification service extension.

Integration with Notification Service Extension

If you're using this package with a notification service extension, you can read the badge count like this:

// In your NotificationService.m
NSURL *containerURL = [[NSFileManager defaultManager] 
    containerURLForSecurityApplicationGroupIdentifier:@"group.com.your.app"];
NSURL *badgeURL = [containerURL URLByAppendingPathComponent:@"RCTAsyncLocalStorage/badge_count"];

NSError *error;
NSString *badgeString = [NSString stringWithContentsOfURL:badgeURL 
                                               encoding:NSUTF8StringEncoding 
                                                  error:&error];
NSInteger count = badgeString ? [badgeString integerValue] : 0;

// Update badge count
count += 1;
self.bestAttemptContent.badge = @(count);

// Save back to shared storage
NSString *newCountString = [NSString stringWithFormat:@"%ld", (long)count];
[newCountString writeToURL:badgeURL 
                atomically:YES 
                  encoding:NSUTF8StringEncoding 
                     error:&error];

API

getContainerURL(groupIdentifier: string): Promise

Returns a promise that resolves with the container URL for the specified app group.

  • groupIdentifier: The identifier of your app group (e.g., "group.com.your.app")
  • Returns: A promise that resolves with the absolute string URL of the app group container
  • Throws: An error if the app group is not found or if called on a non-iOS platform

setBadgeCount(groupIdentifier: string, count: number): Promise

Sets a badge count value in the app group container that can be accessed by other apps in the same group.

  • groupIdentifier: The identifier of your app group (e.g., "group.com.your.app")
  • count: The badge count number to set
  • Returns: A promise that resolves with the string representation of the count that was set
  • Throws: An error if the app group is not found or if called on a non-iOS platform

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library