Skip to content

Commit e4b2580

Browse files
committed
Update Setup Docs
1 parent 2709b40 commit e4b2580

File tree

2 files changed

+88
-41
lines changed

2 files changed

+88
-41
lines changed

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"cSpell.words": [
3+
"barthelemy",
4+
"chua",
5+
"cocoapod",
6+
"cocoapods",
7+
"jrichardlai",
8+
"kachanovskyi",
9+
"zanechua",
10+
"zendesk",
11+
"zopim"
12+
]
13+
}

README.md

Lines changed: 75 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,90 +4,124 @@ Simple module that allows displaying Zopim Chat from Zendesk for React Native.
44

55
## VERSIONS
66

7-
For RN version higher than 0.59 use version >= 0.3.0
8-
9-
For RN version lower than 0.59 use version <= 0.2.2
7+
- For RN version higher than 0.59 use version >= 0.3.0 (Zendesk Chat v1)
8+
- For RN version lower than 0.59 use version <= 0.2.2 (Zendesk Chat v1)
109

1110
## Known Issues
1211

1312
## Getting Started
1413

1514
Follow the instructions to install the SDK for [iOS](https://developer.zendesk.com/embeddables/docs/ios-chat-sdk/introduction) and [Android](https://developer.zendesk.com/embeddables/docs/android-chat-sdk/introduction).
1615

17-
### Manual install
16+
With npm:
1817

19-
1. With npm:
18+
`npm install react-native-zendesk-chat --save`
2019

21-
`npm install react-native-zendesk-chat --save`
20+
or with yarn:
2221

23-
or with yarn:
22+
`yarn add react-native-zendesk-chat`
2423

25-
`yarn add react-native-zendesk-chat`
24+
### QuickStart & Usage
2625

27-
#### iOS
26+
1. Setup Native Dependencies<br/> **iOS** If you're on react-native >= 0.60 and you have Cocoapods setup, then you just need to:
2827

29-
2. Add a reference to your Podfile:
28+
```bash
29+
$ yarn install # and see if there are any errors
30+
$ (cd ios; pod install) # and see if there are any errors
31+
# -- you may need to do `pod install --repo-update`
32+
```
3033

31-
`pod 'RNZendeskChat', :git => 'https://github.com/robertmurray/react-native-zendesk-chat.git'`
34+
If you're on older react-native versions, please see the [Advanced Setup](#advanced-setup) section below
3235

33-
then run pod install: `(cd ios; pod install)`
36+
**Android** If you're on react-native >= 0.60, Android should autodetect this dependency. You may need to call `react-native link`
3437

35-
or manually:
38+
1. Call the JS Initializer:
3639

37-
In Xcode, drag and drop `node_modules/react-native-zendesk-chat/RNZendeskChat.m` and `node_modules/react-native-zendesk-chat/RNZendeskChat.h` into your project.
40+
```javascript
41+
import ZendeskChat from "react-native-zendesk-chat";
3842

39-
3. Configure `ZDCChat` in `AppDelegate.m`:
43+
// Once in your application:
44+
ZendeskChat.init("YOUR_ZENDESK_ACCOUNT_KEY");
45+
```
4046

47+
1. Show the Chat UI
48+
49+
```javascript
50+
// On button press, when you want to show chat:
51+
ZendeskChat.startChat({
52+
name: user.full_name,
53+
email: user.email,
54+
phone: user.mobile_phone,
55+
tags: ["tag1", "tag2"],
56+
department: "Your department",
57+
});
4158
```
59+
60+
### Advanced Setup
61+
62+
Advanced users, or users running on older versions of react-native may want to initialize things in native.
63+
64+
#### iOS: Manually Setting up with Cocoapods
65+
66+
If you're on iOS < 0.60, you may need to manually install the cocoapod:
67+
68+
Add a reference to your Podfile:
69+
70+
```Podfile
71+
pod 'RNZendeskChat', :git => 'https://github.com/taskrabbit/react-native-zendesk-chat.git'
72+
```
73+
74+
then run pod install: `(cd ios; pod install)`
75+
76+
or manually:
77+
78+
In Xcode, drag and drop `node_modules/react-native-zendesk-chat/RNZendeskChat.m` and `node_modules/react-native-zendesk-chat/RNZendeskChat.h` into your project.
79+
80+
#### iOS: Configure `ZDCChat` in `AppDelegate.m`:
81+
82+
```objective-c
4283
#import <ZDCChat/ZDCChat.h>
4384

85+
// ...
86+
87+
// Inside the appropriate appDidFinishLaunching method
4488
[ZDCChat initializeWithAccountKey:@"YOUR_ZENDESK_ACCOUNT_KEY"];
89+
90+
// And access other interesting APIs
4591
```
4692
47-
#### Android
93+
#### Android: Manual Setup & Configuration
94+
95+
If you're on react-native < 0.60, you should be able to call `react-native link`.
96+
97+
If this doesn't work, then you may need to do a complete manual install as follows:
4898
49-
2. Open up `android/app/main/java/[...]/MainApplication.java`
99+
1. Open up `android/app/main/java/[...]/MainApplication.java`
50100
51101
- Add `import com.taskrabbit.zendesk.*;` to the imports at the top of the file
52102
- Add `new RNZendeskChatPackage(this)` to the list returned by the `getPackages()` method
53103
54-
3. Append the following lines to `android/settings.gradle`:
104+
1. Append the following lines to `android/settings.gradle`:
55105
56-
```
106+
```gradle
57107
include ':react-native-zendesk-chat'
58108
project(':react-native-zendesk-chat').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-zendesk-chat/android')
59109
```
60110

61-
4. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
111+
1. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
62112

63-
```
113+
```gradle
64114
compile project(':react-native-zendesk-chat')
65115
```
66116

67-
5. Configure `ZopimChat` in `android/app/main/java/[...]/MainActivity.java`
117+
1. Configure `ZopimChat` in `android/app/main/java/[...]/MainActivity.java`
68118

69-
```
119+
```java
120+
// Note: there is a JS method to do this!
121+
// Call this once in your Activity's bootup lifecycle
70122
ZopimChat.init("YOUR_ZENDESK_ACCOUNT_KEY").build();
71123
```
72124

73-
## Usage
74-
75-
In your code add:
76-
77-
```
78-
import ZendeskChat from 'react-native-zendesk-chat
79-
80-
...
81-
82-
ZendeskChat.startChat({
83-
name: user.full_name,
84-
email: user.email,
85-
phone: user.mobile_phone,
86-
tags: ['tag1', 'tag2'],
87-
department: "Your department"
88-
});
89-
```
90-
91125
## TODO
92126

93127
- Allow setting form configuration from JS

0 commit comments

Comments
 (0)