@aloai/alo-chat-react-native
v0.2.6
Published
TBD
Downloads
28
Readme
ChatWidget API
Installation
yarn add @aloai/alo-chat-react-native
Dependencies
- @react-native-async-storage/async-storage
- @react-native-picker/picker
- react-native-image-picker
Post-install Steps
iOS
Add NSPhotoLibraryUsageDescription
and NSCameraUsageDescription
keys to your Info.plist.
Import
import { ChatWidget } from 'alo-chat-react-native';
// or
import ChatWidget from 'alo-chat-react-native/ChatWidget';
Props
| Name | Type | Required | Default | Description | | -------------------- | ------ | -------- | ------- | ----------------------------------------------------------------------------- | | appId | string | yes | | The ĀLO provided App ID. | | authToken | string | yes | | The ĀLO generated auth token providing secure access to the ĀLO chat servers. | | sendIcon | node | yes | | The icon to be used for the send button. | | uploadIcon | node | yes | | The icon to be used for the upload button. | | userId | string | yes | | A unique ID that identifies the user who is chatting. | | languageSettingsIcon | node | no | en | The icon to be used for the language settings button |
Auth Token Instructions
POST https://auth.alo.ai/v1/auth
Headers:
- Authorization: Bearer <ApiKey>
Payload:
- ttl
- user
Payload
| Key | Type | Required | Default | Description | | ---- | ------ | -------- | ------- | --------------------------------------------------------------------------- | | user | object | yes | | A collection of custom private claims used to share information with ALO | | ttl | number | no | 1440 | Time in minutes for which granted access is valid. Min is 1, Max is 525600. |
User Schema
| Key | Type | Required | Description | | ----------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | id | string | yes | Unique ID for the user to grant access to | | firstName | string | no | First/given name | | lastName | string | no | Last/family name | | email | string | no | Email address | | phoneNumber | string | no | Must start with a plus (+) sign, followed immediately by the country code. A phone number can only contain the + sign and digits. You must remove any other characters from a phone number, such as parentheses, spaces, or dashes (-) before submitting the value to the service. For example, a United States-based phone number must follow this format: +14325551212. |
Example
Request:
POST https://auth.alo.ai/v1/auth
Headers:
- Authorization: Bearer dhPH43dkEJHzMUtlIYSGVt8HE5xOAt2c
Payload:
- user: { id: "9744d434-3216-44f7-b6a3-67ecbbd44aff", firstName: "Michael", lastName: "Jordan", phoneNumber: "+15551234567" }
- ttl: 60
Response:
{ token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" }
Development Instructions
- Set
CHAT_HTTP_ENDPOINT
andCHAT_WS_ENDPOINT
insrc/constants.js
- Set
appId
,authToken
anduserId
inexample/src/App.js
- Install dependencies:
yarn install; cd example; yarn install
- Start React Native development server:
cd example; yarn start
- Deploy example app to device:
yarn example android
oryarn example ios
Release Instructions
- Set values in src/constants.js to production values
- Commit all changes
- If not logged in to npm:
npm login
- Run
yarn release
- Select increment for new version (patch, minor, major)
- Publish @aloai/alo-chat-react-native to npm? Yes
- Commit (Release X.X.X)? No (it will fail because of commit checks)
- Commit the change made to package.json
- Tag the release with the new version number
Example App Release Instructions (iOS)
- Open
example/ios/alochatreactnative.xcworkspace
in XCode - Change the version in the Xcode General tab
- In Menu, select
Product
>Archive
- Select the Archive and click
Distribute App
- Deselect
Include bitcode for iOS content
and complete remaining steps