GithubHelp home page GithubHelp logo

martincik / react-native-google-app-invites Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 3.0 16 KB

Google App Invites for React Native

License: MIT License

Objective-C 52.92% JavaScript 1.09% Java 45.99%

react-native-google-app-invites's Introduction

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

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

iOS

You will need:

CocoaPods (Setup)

Google project configuration for iOS

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
  • In android/setting.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
...
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
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)
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:

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");

react-native-google-app-invites's People

Contributors

martincik avatar guillaumemorin avatar

Stargazers

Hari Velaayutham avatar Cameron King avatar Tarkan Anlar avatar  avatar Rafael Turk avatar Gustavo Gawryszewski avatar Shane Rogers avatar Will Sahatdjian avatar Miguel avatar Jared Roberts avatar  avatar Seong Hoon Lee avatar

Watchers

 avatar Miguel avatar James Cloos avatar Jared Roberts avatar

react-native-google-app-invites's Issues

Thanks

This is not an issue but theres not really a better way to do this. I found the RN Android documentation is lacking in a real working implementation of native to JS event transmission.

Your repo here helped me figure it out so thanks ๐Ÿ’– ๐Ÿ’– ๐Ÿ’–

message not sent alert

Hi @martincik
i have implemented this module as per your guidelines.
I got an alert while sending the message
message failed to sent
how can i solve it.

Advance thanks.
Below is the log

07-14 12:23:09.253 1846 1846 V GLSActivity: AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
07-14 12:23:09.254 1846 1846 V GLSActivity: AuthDelegateWrapperCreated with selected intent: Intent { cmp=com.google.android.gms/.auth.DefaultAuthDelegateService }
07-14 12:23:09.384 1197 1197 D WVCdm : Instantiating CDM.
07-14 12:23:09.391 1197 1947 I WVCdm : CdmEngine::OpenSession
07-14 12:23:09.391 1197 1947 I WVCdm : Level3 Library Sep 28 2015 13:08:28
07-14 12:23:09.392 1197 1947 W WVCdm : Could not read /data/mediadrm/IDM1013/ay64.dat2: No such file or directory
07-14 12:23:09.392 1197 1947 W WVCdm : Could not load liboemcrypto.so. Falling back to L3. dlopen failed: library "liboemcrypto.so" not found
07-14 12:23:09.399 1197 1947 I WVCdm : CdmEngine::QueryKeyControlInfo
07-14 12:23:09.402 1197 1832 W WVCdm : BufferReader::Read : Failure during parse: Not enough bytes (4)
07-14 12:23:09.402 1197 1832 W WVCdm : CdmEngine::ExtractWidevinePssh: Unable to read atom size.
07-14 12:23:09.402 1197 1832 I WVCdm : CdmEngine::GenerateKeyRequest
07-14 12:23:09.403 1197 1832 D WVCdm : PrepareKeyRequest: nonce=3827008932
07-14 12:23:09.413 1526 1537 I AccountManagerService: getTypesVisibleToCaller: isPermitted? true
07-14 12:23:09.419 2809 2822 I GoogleURLConnFactory: Using platform SSLCertificateSocketFactory
07-14 12:23:09.521 1197 1197 I WVCdm : CdmEngine::CloseSession
07-14 12:23:09.974 2809 2822 D : HostConnection::get() New Host Connection established 0xae4678c0, tid 2822
07-14 12:23:10.720 1846 2140 W GLSUser : [AppCertManager] IOException while requesting key:
07-14 12:23:10.720 1846 2140 W GLSUser : java.io.IOException: Invalid device key response.
07-14 12:23:10.720 1846 2140 W GLSUser : at com.google.android.gms.auth.be.appcert.a.a(SourceFile:268)
07-14 12:23:10.720 1846 2140 W GLSUser : at com.google.android.gms.auth.be.appcert.a.a(SourceFile:132)
07-14 12:23:10.720 1846 2140 W GLSUser : at com.google.android.gms.auth.be.appcert.a.a(SourceFile:171)
07-14 12:23:10.720 1846 2140 W GLSUser : at com.google.android.gms.auth.be.appcert.b.a(SourceFile:61)
07-14 12:23:10.720 1846 2140 W GLSUser : at com.google.android.gms.auth.b.f.onTransact(SourceFile:58)
07-14 12:23:10.720 1846 2140 W GLSUser : at android.os.Binder.execTransact(Binder.java:453)
07-14 12:23:10.728 2698 2912 W BaseAppContext: Using Auth Proxy for data requests.
07-14 12:23:11.171 2698 2912 E AppInviteAgent: Create invitations failed due to error code: 13
07-14 12:23:11.334 2634 2658 I ReactNativeJS: 'ERROR App Invites in', { message: 'Sending failed or it was canceled' }
07-14 12:23:11.335 2634 2658 I ReactNativeJS: 'ERROR App Invites in', { message: 'Sending failed or it was canceled' }
07-14 12:23:11.335 2634 2658 I ReactNativeJS: 'ERROR App Invites in', { message: 'Sending failed or it was canceled' }

Message not send(Without any error)

Hi,

This is a great package for google app invite.I can set message text ,title and select contacts to whom I want to send invite.After sending invite button,I returned to my page.But I unable to receive the message of app invite.I had followed all the steps as mentioned in package.I had also enable deep linking and added SHA-1 and SHA-256 on firebase console.I send only normal text less than 20 character length as below without any special character.

Message Text : www.google.com

Please can you help? I stucked here.

Thank you.

Build failed

Hi Ladislav,

I'm trying to build my app with react-native-google-app-invites but on build i'm receiving the error below, do you have an idea on what could be the reason of this? Thx in advance!

FAILURE: Build failed with an exception.

does this lib work w React Native 0.40+ ?

hi there, have a requirement for this feature and found your lib. Does it support RN 0.40+ and also are you planning on maintaining it (not essential but just curious). Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.