react-native-google-contact-api
v1.1.1
Published
A package for retrieving Google Contacts and OtherContacts from Google.
Downloads
20
Readme
react-native-google-contact-api
A React Native package that facilitates the retrieval of Google Contacts and Other Contacts from Google. This package utilizes the react-native-google-contact-api
library, providing a simple and efficient way to integrate Google Contacts functionality into your React Native applications.
Installation
npm install react-native-google-contact-api
Android Configuration Guide
Firebase Configuration
Obatain SHA1 Key from the KeyStore file, add it to the Firebase Console by following these steps:
- Sign in to Firebase and open your project.
- Click the Settings icon and select Project settings.
- In the Your apps card, select the package name of the app you need to add SHA1 to.
- Click "Add fingerprint."
Then, go to Firebase Console, select your app, and add the SHA1 value under Project Settings (gear icon in the upper left) -> Your Apps - SHA certificate fingerprints.
You can get your webClientId
from Google Developer Console.
Steps To Generate OAUTH2 webClientId
- Create credentials using OAUTH Client ID Configuration.
- Select Application Type as Web Application.
- Add your Application name and Redirect URI.
- The WebClient Id is generated for your application.
Gradle Configuration
If you're running your app in debug mode and not using webClientId
or you're sure it's correct, the problem might be a signature (SHA-1 or SHA-256) mismatch. Add the following to android/app/build.gradle
:
signingConfigs {
debug {
// Add your signing configuration details here
}
release {
// Add your signing configuration details here
}
}
And Then
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
.....
}
IOS Configuration Guide
Firebase Configuration
You can get your webClientId
from Google Developer Console.
- Create Credentials By using OAUTH Client ID Configuration
- Select Application Type As IOS
- Add Your IOS Application name and Bundle Id
- WebClient Id is Generated for Your Application
Usage
Before you can fetch contacts, you need to register your credentials. This process involves obtaining the necessary API keys, tokens, or any other authentication information required by the service or library you are using for contact retrieval.
To register your credentials and integrate them into your React Native application, follow the example code below. This example demonstrates the process of registering API keys for Google Contacts using the react-native-google-contact-api library.
RegisterGoogleClientService
import {
FetchGoogleContactService,
FetchGoogleOtherContactService,
RegisterGoogleClientService,
ContactResponseDataProps,
RegisterResponseProps,
userDataProps,
} from 'react-native-google-contact-api';
....
let userData: userDataProps = {
ClientId: 'ClientId', // Android or IOS Client id Required
rediectUrl: 'rediectUrl', // Required for IOS
appId: 'appId', // Required for Android
ClientSecret: 'ClientSecret', // Required for Android
};
RegisterGoogleClientService(userData)
.then((res: RegisterResponseProps) => {
// Response Data
})
.catch((e: any) => {
// Error Response
});
There are two types of Contact Fetching Methods available in this Package.
- FetchGoogleContactService
- FetchGoogleOtherContactService
Fetch GoogleContact Service
When dealing with paginated data, services often provide a next_page_token
as part of the API response to help fetch subsequent pages of data.
FetchGoogleContactService(next_page_token) // ===> next_page_token is Optional
.then((res: ContactResponseDataProps) => {
// Response Data
})
.catch((e: any) => {
// Error Response
});
Fetch GoogleOtherContact Service
When dealing with paginated data, services often provide a next_page_token
as part of the API response to help fetch subsequent pages of data.
FetchGoogleOtherContactService(next_page_token) // ===> next_page_token is Optional
.then((res: ContactResponseDataProps) => {
// Response Data
})
.catch((e: any) => {
// Error Response
});
Response JSON Object
RegisterGoogleClientService()
Method Reponse
| Key | Value | Description |
| ----------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| status | 1 or 0 | 1
- Success, 0
- Failed
| message | Message about Success or Failure |
FetchGoogleContactService()
and FetchGoogleOtherContactService()
Methods Reponse
| Key | Value | Description |
| ---------------- | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status | 1 or 0 | 1
- Success, 0
- Failed |
| nextPageToken | String | Next page token response from Google.it will return null when next page is empty |
| data | User Array List | response user data from Google |
message | |Message will receive only Failure
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT