From d48d4e5884c8c94ffcfee8002b3912eb999040ab Mon Sep 17 00:00:00 2001 From: Simone Date: Mon, 22 Nov 2021 09:49:08 +0100 Subject: [PATCH 1/9] add function signatures --- index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.d.ts b/index.d.ts index a08d1f1..9ad12a8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; From 076845771b60c537320c90c504a983246a86cf5a Mon Sep 17 00:00:00 2001 From: Simone Date: Tue, 23 Nov 2021 14:52:37 +0100 Subject: [PATCH 2/9] add android open and show tickets operation --- .../rnzendeskchat/RNZendeskChat.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java index ce47f27..2858f12 100644 --- a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java +++ b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java @@ -165,18 +165,29 @@ public void setUserIdentity(ReadableMap options) { checkIdentity(); } + @ReactMethod + public void openTicket(){ + Activity activity = getCurrentActivity(); + + // Custom Field for the category + CustomField customFieldOne = new CustomField(1900002821093L, "Cashback"); + + // Open a ticket + RequestActivity.builder(). + withCustomFields(Arrays.asList(customFieldOne)).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 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) { From 9f7c2277d53300a7375f5a9cace19a5dbf097bb7 Mon Sep 17 00:00:00 2001 From: Simone Date: Tue, 23 Nov 2021 17:31:14 +0100 Subject: [PATCH 3/9] add open a ticket function IOS --- ios/RNZendeskChat.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ios/RNZendeskChat.m b/ios/RNZendeskChat.m index 4577d38..8b4d888 100644 --- a/ios/RNZendeskChat.m +++ b/ios/RNZendeskChat.m @@ -59,6 +59,14 @@ @implementation RNZendeskChat }); } +RCT_EXPORT_METHOD(openTicket) { + [self setVisitorInfo:options]; + + dispatch_sync(dispatch_get_main_queue(), ^{ + [self openTicketFunction]; + }); +} + RCT_EXPORT_METHOD(showHelpCenter:(NSDictionary *)options) { [self setVisitorInfo:options]; dispatch_sync(dispatch_get_main_queue(), ^{ @@ -142,6 +150,17 @@ - (void) showHelpCenterFunction:(NSDictionary *)options { [topController presentViewController:navControl animated:YES completion:nil]; } +- (void) openTicket { + UIViewController *requestList = [ZDKRequestUi buildRequestUiWith:@[]]; + UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController; + while (topController.presentedViewController) { + topController = topController.presentedViewController; + } + UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: controller]; + [navControl pushViewController:requestList animated:YES]; + [topController presentViewController:navControl animated:YES completion:nil]; + } + - (void) startChatFunction:(NSDictionary *)options { ZDKMessagingConfiguration *messagingConfiguration = [[ZDKMessagingConfiguration alloc] init]; NSString *botName = @"ChatBot"; From 80517c512afd084505061bd61057d05700a26e3e Mon Sep 17 00:00:00 2001 From: Simone Date: Wed, 24 Nov 2021 09:59:13 +0100 Subject: [PATCH 4/9] fix ios errors --- ios/RNZendeskChat.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ios/RNZendeskChat.m b/ios/RNZendeskChat.m index 8b4d888..45bdf99 100644 --- a/ios/RNZendeskChat.m +++ b/ios/RNZendeskChat.m @@ -60,7 +60,6 @@ @implementation RNZendeskChat } RCT_EXPORT_METHOD(openTicket) { - [self setVisitorInfo:options]; dispatch_sync(dispatch_get_main_queue(), ^{ [self openTicketFunction]; @@ -150,13 +149,13 @@ - (void) showHelpCenterFunction:(NSDictionary *)options { [topController presentViewController:navControl animated:YES completion:nil]; } -- (void) openTicket { +- (void) openTicketFunction { UIViewController *requestList = [ZDKRequestUi buildRequestUiWith:@[]]; UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController; while (topController.presentedViewController) { topController = topController.presentedViewController; } - UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: controller]; + UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: requestList]; [navControl pushViewController:requestList animated:YES]; [topController presentViewController:navControl animated:YES completion:nil]; } From 1d503745528664d776a20f876162481467a0639c Mon Sep 17 00:00:00 2001 From: Simone Date: Wed, 24 Nov 2021 11:39:56 +0100 Subject: [PATCH 5/9] fix java errors --- .../java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java index 2858f12..931f537 100644 --- a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java +++ b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java @@ -169,12 +169,13 @@ public void setUserIdentity(ReadableMap options) { public void openTicket(){ Activity activity = getCurrentActivity(); + List customFields = new ArrayList<>(); // Custom Field for the category - CustomField customFieldOne = new CustomField(1900002821093L, "Cashback"); + customFields.add(new CustomField(1900002821093L, "Cashback")); // Open a ticket RequestActivity.builder(). - withCustomFields(Arrays.asList(customFieldOne)).show(activity); + withCustomFields(customFields).show(activity); } @ReactMethod From 70ae1ea4dd8cf7679095ca1134007aa189c0e923 Mon Sep 17 00:00:00 2001 From: Simone Date: Wed, 24 Nov 2021 12:09:07 +0100 Subject: [PATCH 6/9] import missing library --- .../main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java index 931f537..67155fe 100644 --- a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java +++ b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java @@ -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 { From 6b2dce1bf8d5e5e7b2bdf6c192aff8cf4e9e72ca Mon Sep 17 00:00:00 2001 From: Simone Date: Wed, 24 Nov 2021 14:39:40 +0100 Subject: [PATCH 7/9] add show tickets and update open ticket --- ios/RNZendeskChat.m | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ios/RNZendeskChat.m b/ios/RNZendeskChat.m index 45bdf99..13befd5 100644 --- a/ios/RNZendeskChat.m +++ b/ios/RNZendeskChat.m @@ -60,11 +60,15 @@ @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]; @@ -150,13 +154,22 @@ - (void) showHelpCenterFunction:(NSDictionary *)options { } - (void) openTicketFunction { - UIViewController *requestList = [ZDKRequestUi buildRequestUiWith:@[]]; + 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: requestList]; - [navControl pushViewController:requestList animated:YES]; + UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController: showTicketsController]; [topController presentViewController:navControl animated:YES completion:nil]; } From 07d58ffd87a7002d66c37316c2ec4d121e9fb428 Mon Sep 17 00:00:00 2001 From: Simone Date: Wed, 24 Nov 2021 14:40:02 +0100 Subject: [PATCH 8/9] upgrade version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c31c698..6428ee4 100644 --- a/package.json +++ b/package.json @@ -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": { From 37c52056af4063e6163ec801b7e1df24242e219a Mon Sep 17 00:00:00 2001 From: Simone Date: Wed, 24 Nov 2021 17:00:46 +0100 Subject: [PATCH 9/9] removed test custom data --- .../java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java index 67155fe..e1de74e 100644 --- a/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java +++ b/android/src/main/java/com/saranshmalik/rnzendeskchat/RNZendeskChat.java @@ -170,10 +170,6 @@ public void setUserIdentity(ReadableMap options) { public void openTicket(){ Activity activity = getCurrentActivity(); - List customFields = new ArrayList<>(); - // Custom Field for the category - customFields.add(new CustomField(1900002821093L, "Cashback")); - // Open a ticket RequestActivity.builder(). withCustomFields(customFields).show(activity);