Issue #521
#import <React/RCTBridgeModule.h>
@interface RNSurveyManager : NSObject <RCTBridgeModule>
@end
#import "RNSurveyManager.h"
#import <React/RCTLog.h>
#import <SurveyMonkeyiOSSDK/SurveyMonkeyiOSSDK.h>
@interface RNSurveyManager()<SMFeedbackDelegate>
@property (nonatomic, strong) SMFeedbackViewController * feedbackController;
@end
@implementation RNSurveyManager
- (instancetype)init {
self = [super init];
if (self) {
self.feedbackController = [[SMFeedbackViewController alloc] initWithSurvey:@"VV8X5QA"];
self.feedbackController.delegate = self;
}
return self;
}
+ (BOOL)requiresMainQueueSetup {
return YES;
}
- (dispatch_queue_t)methodQueue {
return dispatch_get_main_queue();
}
RCT_EXPORT_MODULE(SurveyManager);
- (void)respondentDidEndSurvey:(SMRespondent *)respondent error:(NSError *)error {
NSLog(@"respondent %@ error %@", respondent, error);
}
RCT_EXPORT_METHOD(show:(RCTResponseSenderBlock)callback) {
[UIApplication.sharedApplication.keyWindow.rootViewController
presentViewController:self.feedbackController
animated:YES
completion:^() {
callback(@[]);
}];
}
@end
// @flow
import { NativeModules } from 'react-native'
type SurveyManagerType = {
show: () => void
}
const SurveyManager: SurveyManagerType = NativeModules.SurveyManager
export default SurveyManager