Skip to content

Updates to support Cocoapods for RN 0.62 #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) TaskRabbit, Inc. and its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 40 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,38 @@ Simple module that allows displaying Zopim Chat from Zendesk for React Native.

## VERSIONS

For RN version higher than 0.30 use version >= 0.1.x
For RN version higher than 0.59 use version >= 0.3.0

For RN version lower than 0.30 use version 0.0.2.
For RN version lower than 0.59 use version <= 0.2.2

Since version 0.2.0 `department` is set to `ZDCPreChatDataRequiredEditable`.
## Known Issues

## Known issues

I could not find how to make the import for iOS work properly since I'm using Cocoapods for Zendesk, if you have a suggestion that would be great.

## Getting started
## Getting Started

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).

### Manual install

1. With npm:

`npm install react-native-zendesk-chat --save`

or with yarn:

`yarn add react-native-zendesk-chat`

#### iOS
1. `npm install react-native-zendesk-chat --save`
2. 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.

2. Add a reference to your Podfile:

`pod 'RNZendeskChat', :git => 'https://github.com/robertmurray/react-native-zendesk-chat.git'`

then run pod install: `(cd ios; pod install)`

or manually:

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.

3. Configure `ZDCChat` in `AppDelegate.m`:

```
Expand All @@ -31,10 +45,11 @@ Follow the instructions to install the SDK for [iOS](https://developer.zendesk.c
```

#### Android
1. `npm install react-native-zendesk-chat --save`
2. Open up `android/app/main/java/[...]/MainActivity.java`
- Add `import com.taskrabbit.zendesk.*;` to the imports at the top of the file
- Add `new RNZendeskChatPackage(this)` to the list returned by the `getPackages()` method

2. Open up `android/app/main/java/[...]/MainApplication.java`

- Add `import com.taskrabbit.zendesk.*;` to the imports at the top of the file
- Add `new RNZendeskChatPackage(this)` to the list returned by the `getPackages()` method

3. Append the following lines to `android/settings.gradle`:

Expand All @@ -57,9 +72,13 @@ ZopimChat.init("YOUR_ZENDESK_ACCOUNT_KEY").build();

## Usage

In your code add `import ZendeskChat from 'react-native-zendesk-chat';`.
In your code add:

```
import ZendeskChat from 'react-native-zendesk-chat

...

ZendeskChat.startChat({
name: user.full_name,
email: user.email,
Expand All @@ -71,5 +90,9 @@ ZendeskChat.startChat({

## TODO

* Allow setting form configuration from JS
* Add examples
- Allow setting form configuration from JS
- Add examples

## License

React Native is MIT licensed, as found in the [LICENSE](https://github.com/taskrabbit/react-native-zendesk-chat/LICENSE) file.
22 changes: 22 additions & 0 deletions RNZendeskChat.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = "RNZendeskChat"
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.authors = package['author']
s.homepage = package['homepage']
s.platform = :ios, "10"
s.source = { :git => "https://github.com/taskrabbit/react-native-zendesk-chat.git", :tag => "v#{s.version}" }
s.source_files = "ios/*.{h,m}"
s.static_framework = true

s.framework = 'Foundation'
s.framework = 'UIKit'

s.dependency 'React'
s.dependency 'ZDCChat'
end
29 changes: 16 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

buildscript {
Expand All @@ -8,30 +10,31 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
google()
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion safeExtGet('compileSdkVersion', 23)
buildToolsVersion safeExtGet('buildToolsVersion', "23.0.1")
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', "28.0.3")

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 22)
versionCode 1
versionName "1.0"
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
}
}

repositories {
mavenCentral()
maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' }
jcenter()
google()
maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
}

dependencies {
compile "com.facebook.react:react-native:+"
compile group: 'com.zopim.android', name: 'sdk', version: '1.4.2'
implementation "com.facebook.react:react-native:+"
implementation group: 'com.zopim.android', name: 'sdk', version: '1.4.8'
}
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.taskrabbit.zendesk.RNZendeskChat" >
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.taskrabbit.zendesk" >
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.zopim.android.sdk.api.ZopimChat;
import com.zopim.android.sdk.prechat.PreChatForm;
import com.zopim.android.sdk.model.VisitorInfo;
import com.zopim.android.sdk.prechat.ZopimChatActivity;

Expand Down Expand Up @@ -48,7 +49,16 @@ public void setVisitorInfo(ReadableMap options) {

@ReactMethod
public void init(String key) {
ZopimChat.init(key);
PreChatForm defaultPreChat = new PreChatForm.Builder()
.name(PreChatForm.Field.REQUIRED)
.email(PreChatForm.Field.REQUIRED)
.phoneNumber(PreChatForm.Field.REQUIRED)
.department(PreChatForm.Field.REQUIRED_EDITABLE)
.message(PreChatForm.Field.REQUIRED)
.build();
ZopimChat.init(key)
.preChatForm(defaultPreChat)
.build();
}

@ReactMethod
Expand Down
6 changes: 5 additions & 1 deletion ios/RNZendeskChatModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @implementation RNZendeskChatModule
if (options[@"phone"]) {
visitor.phone = options[@"phone"];
}
visitor.shouldPersist = options[@"shouldPersist"] || NO;
visitor.shouldPersist = [options[@"shouldPersist"] boolValue] || NO;
}];
}

Expand All @@ -48,4 +48,8 @@ @implementation RNZendeskChatModule
});
}

RCT_EXPORT_METHOD(init:(NSString *)zenDeskKey) {
[ZDCChat initializeWithAccountKey:zenDeskKey];
}

@end
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-zendesk-chat",
"version": "0.2.2",
"version": "0.3.0",
"description": "React Native Wrapper around Zopim Zendesk Chat",
"main": "index.js",
"repository": {
Expand All @@ -16,6 +16,15 @@
"android",
"react-component"
],
"homepage": "https://github.com/taskrabbit/react-native-zendesk-chat.git",
"bugs": "https://github.com/taskrabbit/react-native-zendesk-chat/issues",
"author": "jrichardlai",
"license": "MIT"
"contributors": [
"Robert Murray <[email protected]>"
],
"license": "MIT",
"peerDependencies": {
"react": "^16.11.0",
"react-native": "^0.60.0"
}
}
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1