# react-native-followanalytics

> FollowAnalytics React Native SDK

Latest version **4.0.0** (published 2022-07-04) · IST license · 0 weekly downloads

## Install

```sh
npm install react-native-followanalytics
pnpm add react-native-followanalytics
yarn add react-native-followanalytics
bun add react-native-followanalytics
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2022-07-04 |
| First published | 2019-03-22 |
| Weekly downloads | 0 |
| License | IST |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 33 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | FollowAnalytics |
| Maintainers | followanalytics |
| Keywords | react-native |

## Links

- npm: https://www.npmjs.com/package/react-native-followanalytics
- npm.io page: https://npm.io/package/react-native-followanalytics

## Recent versions

- 4.0.0 (latest) — 2022-07-04
- 3.3.0 — 2021-02-12
- 3.2.0 — 2021-01-14
- 3.1.0 — 2020-11-02
- 3.0.1 — 2020-09-18
- 3.0.0 — 2020-09-04
- 2.1.0 — 2020-06-25
- 2.0.0 — 2020-04-01
- 1.1.1 — 2019-12-20
- 1.1.0 — 2019-10-30
- 1.0.2 — 2019-07-26
- 1.0.1 — 2019-03-22

## README

# FollowAnalytics React Native SDK

## Getting started

#### Requirements
- React Native >= 0.58.0
- Reac Native cli >= 2.0.1
- Cocoapods (iOS)
- Gradle (Android)

### Mostly automatic installation

`$ npm install react-native-followanalytics --save`

`$ react-native link react-native-followanalytics`

### Manual installation

`$ npm install PATH_FOR_THE_SDK --save`
`$ react-native link react-native-followanalytics`


#### iOS

If you're using Cocoapods add the following to your application target on the `Podfile`:

	use_frameworks!
	pod 'FollowAnalytics', path: '../node_modules/react-native-followanalytics/ios/Frameworks'
	
Run `pod install` to add the required dependencies.

If you use it manually follow the following steps:

1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-followanalytics` and add `RNFollowanalytics.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNFollowanalytics.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)

You'll still need to integrate the FollowAnalytics iOS SDK. Please follow the [Install using Cocoapods](http://dev.followanalytics.com/sdks/ios/documentation/#install-using-cocoapods) and [Initialize with your API key](http://dev.followanalytics.com/sdks/ios/documentation/#initialize-with-your-api-key) from the [FollowAnaltyics Dev Portal](http://dev.followanalytics.com/).


In your `AppDelegate.h` add the following lines:

	#import <FollowAnalytics/FollowAnalytics.h>

In your `AppDelegate.m` add the following lines inside the `- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions` method

        FollowAnalyticsConfiguration* configuration = [FollowAnalyticsConfiguration
            configurationWith:^(FollowAnalyticsMutableConfiguration * _Nonnull c) {
                c.apiKey = @"YOUR_API_KEY_HERE";
                c.appGroup = @"YOUR_APP_GROUP_HERE";
                c.debug = true;
                c.isDataWalletEnabled = YES;
                c.onDataWalletPolicyChange = ^{
                    [self policyDidChange];
                };
            }];
        [FollowAnalytics startWithConfiguration:configuration
            startupOptions:launchOptions];
        [FAFollowApps storeMessagesPush:YES inApp:YES];
        [FABadge enable];
        [FAFollowApps enableGeoffencing];

#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`
  - Add `import com.followanalytics.reactnative.sdk.RNFollowAnalyticsPackage;` to the imports at the top of the file
  - Add `new RNFollowAnalyticsPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
  	```
  	include ':react-native-followanalytics'
  	project(':react-native-followanalytics').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-followanalytics/android')
  	```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  	```
      compile project(':react-native-followanalytics')
  	```

  - Add `new RNFollowanalyticsReactNativeSdkPackage()` to the `List<IReactPackage>` returned by the `Packages` method

You'll also need to integrate the FollowAnalytics Android SDK to the native part of the application. Please follow the [Install using Gradle](http://dev.followanalytics.com/sdks/android/documentation/#install-using-gradle) and [Initialize with your API key](http://dev.followanalytics.com/sdks/android/documentation/#initialize-with-your-api-key) from the [FollowAnaltyics Dev Portal](http://dev.followanalytics.com/).


## Available methods

The FollowAnalytics React Native SDK makes use of callbacks to get results from method calls, where it applies. Here+s a list of the available methods:

	// all methods using callbacks follow the pattern:
	
	functionName: function((error, result) => {
		if (error) {
			... treat error case here ...
		} else {
			... treat success case here ...
		}
	});

	getOptInAnalytics((error, result) => { ... }});
	setOptInAnalytics(isOptIn);

	requestNotificationAuthorization(); // iOS only
	requestProvisionalNotificationAuthorization(); // iOS only
	
	getUserId(error, result) => { ... }});
	setUserId(user_id);
	
	getDeviceId(error, result) => { ... }});
	
	logEvent("anEventName", "anEventDetail");
	logError("anErrorName", "anErrorDetail");
	logLocationCoordinates(48.8410646, 2.3210844);
	logLocationPosition(position); // Takes a Position object provided by the Geolocation API

	Gender: {
		MALE: 1,
	    FEMALE: 2,
	    OTHER: 3
	}
 
	UserAttributes: {
		setFirstName("aFirstName");
		setLastName("aLastName");
		setEmail("something@domain.com");
		setDateOfBirth("2020-02-28");  // Takes a string (yyyy-MM-dd)
		setGender(FollowAnalytics.Gender.MALE); // Also can use FEMALE || OTHER
		setCountry("France");
		setCity("Paris");
		setRegion("Île-de-France");
		setProfilePictureUrl("https://picture_url");
    	setInteger("aKey", 100);
		setDouble("aKey", 10.5);
    	setString("aKey", "aString");
    	setBoolean("aKey", true); // Or false
    	setDate("aKey", "2020-02-28");  // Takes a string (yyyy-MM-dd)
    	setDateTime("aKey", "2020-02-28 18:46:19 +0200");  // Takes a string (yyyy-MM-dd HH:mm:ss Z)
    	clear("aKey");
    	addToSet("aKey", ...elements);
    	removeFromSet("aKey", ...elements);
    	clearSet("aKey");
	}
	
	Push: {
	    getAll(error, result) => { ... }});
	    get(id, (error, result) => { ... });
	    markAsRead(...ids);
	    markAsUnread(...ids);
	    delete(...ids);
	}
 
	InApp: {
		pauseCampaignDisplay();
	    resumeCampaignDisplay();
	    getAll((error, result) => { ... });
	    get(id, (error, result) => { ... });
	    markAsRead(...ids);
	    markAsUnread(...ids);
	    delete(...ids);
	}
 
	DataWallet: {
		getPolicy((error, result) => { ... });
		isRead((error, result) => { ... });
		setIsRead(value);
	}
	
	GDPR: {
		requestToAccessMyData();
		requestToDeleteMyData();
	}
 

## Usage

At the top of your javascript files add:

```javascript
import FollowAnalytics from "react-native-followanalytics";
```

You can now call the methods listed above using `FollowAnalytics.method_name(arguments)`. Some examples:
	
	FollowAnalytics.logEvent("Page view", "Homepage);
	FollowAnalytics.UserAttributes.setFirstName("Michel");
	FollowAnalytics.getDeviceId: function(error, result) => {
		if (error) {
			console.log("Error fetching deviceId");
			console.log(error);
		} else {
			console.log("Got me a deviceId, and it's: " + result.toString());
		}
	}

---
_Source: https://npm.io/package/react-native-followanalytics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
