# react-native-google-app-invites

> Google App Invites for your react native applications

Latest version **0.2.6** (published 2016-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-google-app-invites
pnpm add react-native-google-app-invites
yarn add react-native-google-app-invites
bun add react-native-google-app-invites
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.6 |
| Published | 2016-01-17 |
| First published | 2016-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Ladislav Martincik |
| Maintainers | martincik |
| Keywords | react-component, react-native, google app invites, google invites, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-google-app-invites
- Repository: https://github.com/slowpath/react-native-google-app-invites
- Issues: https://github.com/slowpath/react-native-google-app-invites/issues
- npm.io page: https://npm.io/package/react-native-google-app-invites

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.6 (latest) — 2016-01-17
- 0.2.5 — 2016-01-04
- 0.2.4 — 2016-01-04
- 0.2.3 — 2016-01-04
- 0.2.2 — 2016-01-04
- 0.2.1 — 2016-01-04
- 0.2.0 — 2016-01-04
- 0.1.0 — 2016-01-02

## README

# react-native-google-app-invites
Let your users sign in with their Google account and Invite your
contacts to use the app.

react-native-google-app-invites is a wrapper around Google App Invites so it can be used from an React Native application.

## Requirements

- iOS 7+
- React Native >0.14
- CocoaPods

## Installation

```bash
npm install react-native-google-app-invites --save
```

## iOS

You will need:

CocoaPods ([Setup](https://guides.cocoapods.org/using/getting-started.html#installation))

### Google project configuration for iOS

- Open https://developers.google.com/app-invites/ios/
- Follow the instalation steps for CocoaPods

## Android

### Google project configuration

- Install `Google Repository` package in `Android SDK Manager`:
1) Run in terminal window `android` (will start Android SDK Manager)
2) Install in `Extras` folder package `Google Repository`

- Open https://developers.google.com/app-invites/android/
- Follow the instalation steps

* In `android/setting.gradle`

```gradle
...
include ':react-native-google-app-invites', ':app'
project(':react-native-google-app-invites').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-app-invites/android')
```

* In `android/build.gradle`

```gradle
...
dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
        classpath 'com.google.gms:google-services:1.5.0' // <--- add this
    }
```

* In `android/app/build.gradle`

```gradle
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services' // <--- add this at the TOP
...
dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.14.+"
    compile project(":react-native-google-app-invites") // <--- add this
}
```

* Register Module (in MainActivity.java)

```java
import com.slowpath.googleappinvites.RNGoogleAppInvitesModule; // <--- import
import com.slowpath.googleappinvites.RNGoogleAppInvitesPackage;  // <--- import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new RNGoogleAppInvitesPackage(this)) // <------ add this line to yout MainActivity class
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "AndroidRNSample", null);

    setContentView(mReactRootView);
  }

  // add this method inside your activity class
  @Override
  protected void onActivityResult(int requestCode, int resultCode, android.content.Intent data) {
      if (requestCode == RNGoogleAppInvitesModule.RC_APP_INVITES_IN) {
          RNGoogleAppInvitesModule.onActivityResult(resultCode, data);
      }
      super.onActivityResult(requestCode, resultCode, data);
  }

  ......

}
```


# Usage

From your JS files for both iOS and Android:

```js
var { NativeAppEventEmitter, DeviceEventEmitter } = require('react-native');
var GoogleAppInvites = require('react-native-google-app-invites');

if (Platform.OS === "ios") {
  GoogleAppInvites.configure(
    CLIENT_ID, // from .plist file
    SCOPES // array of authorization names: eg ['https://www.googleapis.com/auth/plus.login']
  );
} else {
  GoogleAppInvites.init()
}

let Emitter = (Platform.OS === "android") ? DeviceEventEmitter : NativeAppEventEmitter;

Emitter.addListener('googleAppInvitesError', (error) => {
  console.log('ERROR App Invites in', error);
});

Emitter.addListener('googleAppInviteIds', (body) => {
  console.log('User invited these IDS:', body);
});

GoogleAppInvites.invite("Message", "Title", "http://deepLink");
```

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