React Native Guide

Requirements

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

Installation

The SDK is available through npm and to include it in your React Native project use the following command.

$ npm install react-native-grow-sdk

Dependencies

If you want to send location events you need to include in your project the following dependency:

Geolocation from react-native-geolocation-service https://www.npmjs.com/package/react-native-geolocation-service

iOS Integration

To fetch the native dependencies open the terminal and from your project ios folder run pod install.

$ cd ios
$ pod install

After these steps you will need to follow the native steps on Xcode to complete the iOS integration which are:

Please verify the iOS integration by checking the following chapter

Android Integration

To make our SDK work on the Android side you need to follow the native steps which are:

Please verify the Android integration by checking the following chapter

Advanced – Usage guide

Device

These methods allow you to identify users and manage notification and tracking consent

From the Device interface you have access to:

  • User identifier
  • Device identifier
  • Analytics enabled
  • Open Notification Settings If Needed Get Notifications Allowed
  • Request Notifications Authorization (iOS only)
  • Request Provisional Notifications Authorization (iOS only)

Identify Users

The following methods allow you to retrieve or value an identifier.

The Device ID is generated by GROW. It is not editable.

Retrieving User Identifier

String userId = Grow.Device.getUserId()

Updating User Identifier

Grow.Device.setUserId("new_user_id");

Retrieving Device Identifier

String deviceId = Grow.Device.getDeviceId()

Analytics

The following methods allow you to manage user analytics by GROW SDK.

For reporting activity logs from the tagging plan (User Identifier, Attributes & Events), analytics must be enabled in the SDK.

By default, analytics are disabled and can be turned on by changing the analytics state of the SDK

Retrieving Analytics Enabled Status

boolean analyticsEnabled = Grow.Device.getAnalyticsEnabled()

Updating Analytics Status

boolean enabled = true/false;
Grow.Device.setAnalyticsEnabled(enabled);

Notifications Permissions

The following methods allow you to manage notifications settings according to iOS specificities.

Open Notification Settings If Needed

Grow.Device.openNotificationSettingsIfNeeded();

Get Notifications Allowed

boolean notificationsAllowed = Grow.Device.getNotificationsAllowed();

Request Notifications Authorization

Request Notifications Authorization is available for iOS only!
boolean notificationsAllowed = Grow.Device.requestNotificationAuthorization(); 
[Grow.Device requestNotificationAuthorization];
Grow.Device.requestNotificationAuthorization();

Request Provisional Notifications Authorization

Request Provisional Notifications Authorization is available for iOS only!
Grow.Device.requestProvisionalNotificationAuthorization()
[Grow.Device requestProvisionalNotificationAuthorization];
Grow.Device.requestProvisionalNotificationAuthorization();

Events

These methods are dedicated to the implementation of the tagging plan. They allow you to define events to track the activity of your users

These methods only will work with users who are “opt-in analytics”

From the Events interface, you have access to:

  • Custom events
  • Location events

Send a Simple Custom event

String name = "event_name";
Grow.Events.Custom.create(name).send();

Send a Custom Event with a Parameter

String name = "event_name";
String value = "Parameter value";
String key = "a_key";

Grow.Events.Custom.create(name)
                  .put(key, value)
                  .send();

Send a Location Event

If you wish, you can log the GPS coordinates of your users if they have their GPS enabled and the application is authorized to use these coordinates.
Location location = new Location("");
location.setAltitude(0.1);
location.setLongitude(0.1);
Grow.Events.Location.send(location);

Attributes

These methods are dedicated to the implementation of the tagging plan. They allow you to define the status of a user based on its activity.

These methods will only work with users who are “opt-in analytics”.
Attributes require a defined user identifier.

From the Attributes interface, you have access to:

  • String attributes
  • Number attributes
  • Boolean attributes
  • Date attributes

String Attributes

Setting a String Attribute

String value = "Attribute value";
String key = "a_key";
Grow.Attributes.setString(key, value);

Removing a String Attribute

String key = "a_key";
Grow.Attributes.setString(key, null);

Number Attributes

Setting a Number Attribute

Number value = 10;
String key = "a_key";
Grow.Attributes.setNumber(key, value);

Removing a Number Attribute

String key = "a_key";
Grow.Attributes.setNumber(key, null);

Boolean Attributes

Setting a Boolean Attribute

boolean value = true;
String key = "a_key";
Grow.Attributes.setBoolean(key, value);

Removing a Boolean Attribute

String key = "a_key";
Grow.Attributes.setBoolean(key, null);

Date Attributes

Setting a Date Attribute

Date value = new Date();
String key = "a_key";
Grow.Attributes.setDate(key, value);

Removing a Date Attribute

String key = "a_key";
Grow.Attributes.setDate(key, null);

Campaigns

The following methods allow you to pause and resume the display of in-apps in specific paths of your application.

Pausing Campaign Display

Grow.Device.pauseInAppDisplaying();

Resuming Campaign Display

Grow.Device.resumeInAppDisplaying();

Privacy

These methods allow you to manage the collection and deletion of your users’ data.

From the Privacy interface, you have access to:

  • Request to Collect Data
  • Request to Erase Data
  • Request to Remove Account
  • Set Tracking Allowed

Request to Collect Data

Grow.Privacy.requestToCollectData();

Request to Erase Data

Grow.Privacy.requestToEraseData();

Request to Remove Account

Grow.Privacy.requestToRemoveAccount();

Set Tracking Allowed

The purpose of this method is to track the status of the device related to the Apple tracking transparency and the related consent the user provided.
boolean allowed = true/false;
Grow.Privacy.setTrackingAllowed(allowed);