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

@sendbird/react-native-push-extension

v1.0.1

Published

Push Notifications extension for React-Native

Downloads

190

Readme

@sendbird/react-native-push-extension

Sendbird Push Notifications extension for React-Native

Installation

yarn add @sendbird/react-native-push-extension

Implementation

Use iOS's App Groups for device token tracking and analysis of Sendbird push notifications. Update the AppDelegate.h and AppDelegate.mm files to implement UserNotificationCenterDelegate and configure NotificationServiceExtension.

Modify the AppDelegate.h

// AppDelegate.h
#import <UserNotifications/UNUserNotificationCenter.h>

@interface AppDelegate : RCTAppDelegate<UNUserNotificationCenterDelegate>

Modify the AppDelegate.mm

// AppDelegate.mm

#import "SendbirdNotificationHelper.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // ...

  // SendbirdPushExtension: set app group
  [SendbirdNotificationHelper setAppGroup:@"your.app.group.name"]; // Set your App Groups name here

  // ...
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  // SendbirdPushExtension: register device token
  [SendbirdNotificationHelper didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

Configuring NotificationServiceExtension

Note: This step is optional If your app is already using NotificationServiceExtension.

In the XCode top menu, click [File > New > Target > Notification Service Extension] to create it. create-extension

To link the extension, update the Podfile.

target 'NotificationServiceExtension' do
  // The below use_frameworks part may differ by project, so handle it according to your project's Podfile settings.
  // use_frameworks! :linkage => :static

  pod 'sendbird-notifications-extension', :path => '../node_modules/@sendbird/react-native-push-extension'
end

After making the modifications, connect the module to your project with the npx pod-install command. Then modify the NotificationService file in the NotificationServiceExtension created in XCode.

objc

// NotificationService.m

#import "SendbirdNotificationHelper.h"

@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
  // ...

  // SendbirdPushExtension: set app group
  [SendbirdNotificationHelper setAppGroup:@"your.app.group.name"]; // Set your App Groups name here


  // SendbirdPushExtension: call markPushNotificationAsDelivered()
  [SendbirdNotificationHelper markPushNotificationAsDelivered:self.bestAttemptContent.userInfo completionHandler:nil];

  // ...
}

swift

// NotificationService.swift

import sendbird_notifications_extension

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
  // ...

  // SendbirdPushExtension: set app group
  SendbirdNotificationHelper.setAppGroup("your.app.group.name")

  // SendbirdPushExtension: call markPushNotificationAsDelivered()
  SendbirdNotificationHelper.markPushNotification(asDelivered: bestAttemptContent.userInfo)

  // ...
}

Handling foreground push notifications

iOS typically receives push notifications while the app is in the background. However, notifications can also be delivered when the app is active and in the foreground. If a notification arrives without displaying a banner, it may still be marked as DELIVERED by the Sendbird system. Implement the willPresentNotification method to ensure notifications are presented to the user during these cases.

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
  if (notification.request.content.userInfo[@"sendbird"] != nil) {
    completionHandler(UNNotificationPresentationOptionAlert);
  }
}

Troubleshooting

If you encounter a build error indicating a conflict with Firebase (e.g., [CP-User][RNFB] ~~), adjust the placement of the Embed Frameworks extension in the project's Build Phases.

License

MIT


Made with create-react-native-library