Skip to content

Commit 21b7a78

Browse files
committed
wip. Working on send feedback
1 parent 6031f8c commit 21b7a78

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

bugfender.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,9 @@ export default {
201201
* Get a URL pointing to the Bugfender dashboard page for the device and current session.
202202
* @return {Promise<string>} A Promise with the URL to the page if the Bugfender sdk is initialized otherwise return null.
203203
*/
204-
getSessionUrl: () => Bugfender.getSessionUrl()
204+
getSessionUrl: () => Bugfender.getSessionUrl(),
205+
206+
// working on
207+
// @return {Promise<string>} A Promise with the URL pointing to the feedback information on the Bugfender dashboard or null if SDK is not initialized.
208+
showUserFeedback: () => Bugfender.showUserFeedback()
205209
};

ios/RNBugfender.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#import "RNBugfender.h"
22
#import <BugfenderSDK/BugfenderSDK.h>
3+
#import <React/RCTUtils.h>
34

45
@implementation RNBugfender
56

@@ -137,6 +138,32 @@ @implementation RNBugfender
137138
resolve([Bugfender sendUserFeedbackReturningUrlWithSubject:title message:text].absoluteString);
138139
}
139140

141+
RCT_EXPORT_METHOD(showUserFeedback:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
142+
{
143+
UIViewController * controller = [Bugfender userFeedbackViewControllerWithTitle:@"title"
144+
hint:@"hint"
145+
subjectPlaceholder:@"subject placeholder"
146+
messagePlaceholder:@"message"
147+
sendButtonTitle:@"button title"
148+
cancelButtonTitle:@"Cancel"
149+
completion:^(BOOL feedbackSent, NSURL * _Nullable url) {
150+
if (feedbackSent) {
151+
resolve(url);
152+
} else {
153+
reject(0, @"Feedback not sent", [NSError errorWithDomain:@"Bugfender" code:0 userInfo:nil]);
154+
}
155+
}];
156+
157+
UIViewController* vc = RCTPresentedViewController();
158+
[vc presentViewController:controller animated:YES completion:nil];
159+
160+
/*
161+
* Another option might be using the window.
162+
* But this code might not work for complex native setup, for simple cases, might work
163+
* [UIApplication.sharedApplication.delegate.window.rootViewController presentViewController:controller animated:YES completion:nil];
164+
*/
165+
}
166+
140167
- (dispatch_queue_t)methodQueue
141168
{
142169
return dispatch_get_main_queue();

0 commit comments

Comments
 (0)