Skip to content
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

Manage support operation #6

Merged
merged 9 commits into from
Nov 24, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import zendesk.answerbot.AnswerBotEngine;
import zendesk.support.SupportEngine;
import zendesk.support.request.RequestActivity;
import zendesk.support.requestlist.RequestListActivity;

public class RNZendeskChat extends ReactContextBaseJavaModule {

Expand Down Expand Up @@ -165,18 +166,26 @@ public void setUserIdentity(ReadableMap options) {
checkIdentity();
}

@ReactMethod
public void openTicket(){
Activity activity = getCurrentActivity();

// Open a ticket
RequestActivity.builder().
withCustomFields(customFields).show(activity);
}

@ReactMethod
public void showTickets(){
Activity activity = getCurrentActivity();

// Show the user's tickets
RequestListActivity.builder().show(activity);
}

@ReactMethod
public void showHelpCenter(ReadableMap options) {
Activity activity = getCurrentActivity();
/*
// config must be passed as 2nd parameter to show method
List<CustomField> customFields = new ArrayList<>();
customFields.add(new CustomField(360028434358L, "testValoreDaApp"));
Configuration config = RequestActivity.builder()
.withCustomFields(customFields)
.withTags("tag1","tag2")
.config();
*/
Boolean withChat = getBoolean(options,"withChat");
Boolean disableTicketCreation = getBoolean(options,"withChat");
if (withChat) {
Expand Down
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ declare module 'io-react-native-zendesk' {
// function to display help center UI
export function showHelpCenter(chatOptions: ChatOptions): void;

// function to open a ticket
export function openTicket(): void;

// function to shows all the tickets of the user
export function showTickets(): void;

// function to set visitor info in chat
export function setVisitorInfo(visitorInfo: UserInfo): void;

Expand Down
31 changes: 31 additions & 0 deletions ios/RNZendeskChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ @implementation RNZendeskChat
});
}

RCT_EXPORT_METHOD(openTicket) {
dispatch_sync(dispatch_get_main_queue(), ^{
[self openTicketFunction];
});
}
RCT_EXPORT_METHOD(showTickets) {
dispatch_sync(dispatch_get_main_queue(), ^{
[self showTicketsFunction];
});
}

RCT_EXPORT_METHOD(showHelpCenter:(NSDictionary *)options) {
[self setVisitorInfo:options];
dispatch_sync(dispatch_get_main_queue(), ^{
Expand Down Expand Up @@ -142,6 +153,26 @@ - (void) showHelpCenterFunction:(NSDictionary *)options {
[topController presentViewController:navControl animated:YES completion:nil];
}

- (void) openTicketFunction {
UIViewController *openTicketController = [ZDKRequestUi buildRequestUiWith:@[]];
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: openTicketController];
[topController presentViewController:navControl animated:YES completion:nil];
}

- (void) showTicketsFunction {
UIViewController *showTicketsController = [ZDKRequestUi buildRequestListWith:@[]];
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: showTicketsController];
[topController presentViewController:navControl animated:YES completion:nil];
}

- (void) startChatFunction:(NSDictionary *)options {
ZDKMessagingConfiguration *messagingConfiguration = [[ZDKMessagingConfiguration alloc] init];
NSString *botName = @"ChatBot";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io-react-native-zendesk",
"version": "0.3.6",
"version": "0.3.7",
"description": "React native wrapper for Zendesk Unified SDK",
"main": "index.js",
"scripts": {
Expand Down