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-grow-sdk-beta

v1.0.0-beta.185

Published

Grow your app by engaging your users

Downloads

16

Readme

Grow SDK for React Native v1.0.0-beta.185

Requirements

  • React Native >= 0.60
  • iOS version > 11.0
  • Cocoapods (iOS)
  • Gradle (Android)

Installation of the SDK

Run this installation command from your project root directory:

$ npm install react-native-grow-sdk-beta

For iOS

  1. Run pod install in YOUR_PROJECT/ios:
$ cd ios
$ pod install
  1. Configure Xcode Signing & Capabilities

In order to make the SDK fully functional, it requires the developer to configure capabilities on the Application target and as well on the Extension target. Enable the following capabilities:

Caution: the App Group name needs to be the same on both Application and Extension targets.

To learn more about capabilities please check Apple documentation.

For Android

Add the Grow SDK maven repository in your top-level build.gradle file:

allprojects {
    repositories {
        // ...
        maven {
            url 'https://nexus.bryj.ai/repository/releases/'
        }
    }
}

Initializing the SDK

To initialize the SDK, it is required an API Key provided by the platform.

For iOS

You need to [configure the App Group](# Installation of the SDK) on your Xcode project. Without the App Group, the SDK will not provide "Push+Landing" campaigns to your application.

In your AppDelegate class file, import the GrowSDK framework:

#import <GrowSDK/GrowSDK-Swift.h>

Still in this AppDelegate file find the method application(_:didFinishLaunchingWithOptions:) and on it create a AppConfigurationBuilder instance from the GrowSDK framework. This instance will allow you to generate through the build() method the required AppConfiguration to be passed in the static method start(_:options:) of the main class Grow. This static method also requires the launchOptions.

In the example below, a AppConfigurationBuilder is instantiated with the mandatory apiKey provided by the platform, and the mandatory appGroup configured by the developer on Xcode:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    id <AppConfiguration> configuration = [[[AppConfigurationBuilder alloc]
                                             initWithApiKey:@"YOUR_API_KEY"
                                             appGroup:@"YOUR_APP_GROUP"]
                                            build];
    
    [Grow startWithConfiguration:configuration options:launchOptions];
    
    // ...
    
    return YES;
}

For Android

In your Application class file, call Grow.start(Context, Grow.Configuration) from your Application.onCreate() implementation. The Grow.Configuration required to initialize the SDK is provided by the Grow.ConfigurationBuilder thanks the to build() method.

In the example below, a Grow.Configuration is instantiated with the mandatory apiKey set to a string provided by the platform:

Java

public class MyApplication extends Application {
    
    @Override
    public void onCreate() {
        super.onCreate();
        Grow.start(getApplicationContext(),
                new Grow.ConfigurationBuilder("YOUR_API_KEY")
                        .build());
    }
}

Kotlin

class MyApplication : Application() {
    
    override fun onCreate() {
        super.onCreate()
        
        Grow.start(
            applicationContext,
            Grow.ConfigurationBuilder(apiKey = "YOUR_API_KEY")
                .build()
        )
    }
}

Setup Push Notification

For iOS

In order to handle Grow Push campaigns, you must add a Notification Service extension to your app. Then go to your project configuration and select your Extension Target. From the Frameworks and Libraries add the GrowSDK.xcframework and select Do Not Embed.

From the auto-generated files open the main Notification Service class that extends from UNNotificationServiceExtension and find the method didReceive(_:withContentHandler:). Inside this method create a ExtensionConfigurationBuilder instance from the GrowSDK framework passing mandatory fields apiKey, appGroup, and appBundleIdentifier. This instance will allow you to generate through the build() method the required ExtensionConfiguration to be passed in the static method didReceive(_:forConfiguration:withContentHandler:) of the main class Grow. This static method will return a GrowNotificationService object that you will need to save a reference to be able to forward the serviceExtensionTimeWillExpire() from Apple in case it times out.

Your extension class must look like one of the following depending if you choose Swift or Objective-C:

import UserNotifications
import GrowSDK

class NotificationService: UNNotificationServiceExtension {
    
    var service: GrowNotificationService?
    
    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        
        let configuration = Grow.ExtensionConfigurationBuilder(appGroup: "YOUR_APP_GROUP",
                                                    appBundleIdentifier: "YOUR_APP_BUNDLE_IDENTIFIER")
                                 .build()
                                 
        service = Grow.didReceive(request, forConfiguration: configuration, withContentHandler: contentHandler)
    }
    
    override func serviceExtensionTimeWillExpire() {
        service?.serviceExtensionTimeWillExpire()
    }
}
#import <GrowSDK/GrowSDK-Swift.h>

@interface NotificationService ()
@property (nonatomic, strong) GrowNotificationService *service;
@end

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

    id <ExtensionConfiguration> configuration = [[[ExtensionConfigurationBuilder alloc]
                                                   initAppGroup:@"YOUR_APP_GROUP"
                                                   appBundleIdentifier:@"YOUR_APP_BUNDLE_IDENTIFIER"]
                                                  build];
    
    self.service = [Grow didReceive:request forConfiguration:configuration withContentHandler:contentHandler];
}

- (void)serviceExtensionTimeWillExpire {
    [self.service serviceExtensionTimeWillExpire];
}
@end

For Android

If you haven't done so yet, you will need to register your app with Firebase and to add the Firebase configuration file to your project. To do so, follow the instructions from the official Firebase documentation.

  1. Add the Google Services plugin to the top-level build.gralde file:

    buildscript {
        // ..
        dependencies {
            // ...
            classpath("com.google.gms:google-services:4.3.15")
        }
    }
  2. Add the Firebase Cloud Messaging library dependency in your app-level build.gradle file:

    dependencies {
        // ...
        implementation platform('com.google.firebase:firebase-bom:29.0.0')
        implementation 'com.google.firebase:firebase-messaging-ktx'
    }
  3. Create a class which extends FirebaseMessagingService and override onMessageReceived and onNewToken as following:

    Java

    public class MyFirebaseMessagingService extends FirebaseMessagingService {
           
        @Override
        public void onNewToken(@NonNull String token) {
            super.onNewToken(token);
            Grow.Device.setFirebasePushToken(token);
        }
           
        @Override
        public void onMessageReceived(@NonNull RemoteMessage message) {
            super.onMessageReceived(message);
            Grow.Device.processFirebaseMessage(message);
        }
    }

    Kotlin

    class MyFirebaseMessagingService : FirebaseMessagingService() {
    
        override fun onNewToken(token: String) {
            Grow.Device.setFirebasePushToken(token)
        }
    
        override fun onMessageReceived(message: RemoteMessage) {
            Grow.Device.processFirebaseMessage(message)
        }
    }
  4. Add the service previously created to the AndroidManifest inside your <application> tag. Make sure to set android:name to the relative path to your service:

    <service
        android:name=".MyFirebaseMessagingService"
        android:enabled="true"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>