Installation

The RN SDK is available for installation from GitHub and NPM. Run one of the following commands in the terminal to install it.

yarn add @personaclick/rn-sdk

or

yarn add https://github.com/PersonaClick/rn-sdk.git

Additionally, the following components must be installed:

yarn add @react-native-async-storage/async-storage
yarn add react-native-device-info
yarn add react-native-push-notification
yarn add @react-native-community/push-notification-ios
yarn add @react-native-firebase/app
yarn add @react-native-firebase/messaging
yarn add @notifee/react-native


iOS Additional Installation

Open your "/ios/{projectName}/AppDelegate.mfile, and add the following at the top of the file:

#import <Firebase.h>

Open a terminal window and navigate to the location of the Xcode project for your app

cd ios/
pod install

Update or create a new "firebase.json" file using the following:

{
    "react-native": {
        "messaging_ios_auto_register_for_remote_messages": false
    }
}


On iOS devices, the user is able to toggle Background App Refresh in device's Settings. Furthermore, the Background App Refresh setting will automatically be off if the device is in low power mode.

If the iOS Background App Refresh mode is off, the handler configured in setBackgroundMessageHandler won't be triggered.

On iOS, when Firebase is used and a message is received the device silently starts your application in a background state. To get around this problem, you can configure your application. Use this property to conditionally render null ("nothing") if your app is launched in the background:

// index.js
import { AppRegistry } from 'react-native';

function HeadlessCheck({ isHeadless }) {
  if (isHeadless) {
    // App has been launched in the background by iOS, ignore
    return null;
  }

  return <App />;
}

function App() {
  // Your application
}

AppRegistry.registerComponent('app', () => HeadlessCheck);

To inject a isHeadless prop into your app, please update your AppDelegate.m file as instructed below:

// add this import statement at the top of your `AppDelegate.m` file
#import "RNFBMessagingModule.h"

// in "(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions" method
// Use `addCustomPropsToUserProps` to pass in props for initialization of your app
// Or pass in `nil` if you have none as per below example
// For `withLaunchOptions` please pass in `launchOptions` object
NSDictionary *appProperties = [RNFBMessagingModule addCustomPropsToUserProps:nil withLaunchOptions:launchOptions];

// Find the `RCTRootView` instance and update the `initialProperties` with your `appProperties` instance
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                             moduleName:@"nameOfYourApp"
                                             initialProperties:appProperties];


Special installation for Android

Add the google-services plugin to your android/build.gradle file:

buildscript { 
    dependencies {
        classpath 'com.google.gms:google-services:4.3.4'
        // ...
    }
    // ...
}

Also add the following to the android/app/build.gradle file:

apply plugin: 'com.google.gms.google-services'



Page Navigation




Related Pages