如何在我的iOS应用程序中集成Surveymonkey ios SDK?
ViewController.h 我在我的项目中尝试过以下代码;
#import <UIKit/UIKit.h>
#import <SurveyMonkeyiOSSDK/SurveyMonkeyiOSSDK.h>
@interface ViewController : UIViewController
@property (nonatomic, strong) SMFeedbackViewController * feedbackController;
@end
ViewController.m
#import "ViewController.h"
//static NSString *SAMPLE_SURVEY_HASH=@"e7bvbydjgchg6vyr2qyrzxkq";
//#define SAMPLE_SURVEY_HASH @"43w3IKqgkvJCvRLvKo8BXt_2FrXe_2BVheRgqp5w2R5TC2c_3D"
#define FEEDBACK_QUESTION_ID @"813797519"
#define FEEDBACK_FIVE_STARS_ROW_ID @"9082377273"
#define FEEDBACK_FOUR_STARS_ROW_ID @"9082377274"
#define SAMPLE_APP @"survey_sample"
#define SURVEY_HASH @"LBQK27G"
#define APP_ID @"DH9K6DY"
@interface ViewController () <SMFeedbackDelegate, UIAlertViewDelegate>
@property (weak, nonatomic) IBOutlet UIButton *takeSurveyButton;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
//#define SAMPLE_SURVEY_HASH e7bvbydjgchg6vyr2qyrzxkq;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_feedbackController = [[SMFeedbackViewController alloc] initWithSurvey:SURVEY_HASH];
_feedbackController.delegate = self;
[_feedbackController scheduleInterceptFromViewController:self withAppTitle:@"survey_sample"];
[_feedbackController presentFromViewController:self animated:YES completion:nil];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)didTapTakeSurvey:(id)sender {
}
- (void)respondentDidEndSurvey:(SMRespondent *)respondent error:(NSError *) error {
if (respondent != nil) {
NSLog(@"val is %@",respondent);
SMQuestionResponse * questionResponse = respondent.questionResponses[0];
NSLog(@"val new is %@",questionResponse.questionID);
NSString * questionID = questionResponse.questionID;
if ([questionID isEqualToString:FEEDBACK_QUESTION_ID]) {
SMAnswerResponse * answerResponse = questionResponse.answers[0];
NSString * rowID = answerResponse.rowID;
if ([rowID isEqualToString:FEEDBACK_FIVE_STARS_ROW_ID] || [rowID isEqualToString:FEEDBACK_FOUR_STARS_ROW_ID]) {
[self showAlertWithBody:NSLocalizedString(@"Please rate us in the app store!", @"") hasRateButton:YES];
}
else {
[self showAlertWithBody:NSLocalizedString(@"We'll address the issues you encountered as quickly as possible!", @"") hasRateButton:NO];
}
}
}
else {
NSLog(@"error is %@",error);
}
}
#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
}
else if(buttonIndex == 1)
{
NSString *appStoreURL = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@?mt=8", APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStoreURL]];
}
}
- (void) showAlertWithBody:(NSString *)body hasRateButton:(BOOL)hasRateButton {
UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:NSLocalizedString(@"Thanks for your feedback!", @"Heading for feedback prompt")
message:body
delegate:self
cancelButtonTitle: NSLocalizedString(@"Cancel", @"Title of cancel button on app store rating prompt")
otherButtonTitles: nil];
if (hasRateButton) {
[alert addButtonWithTitle:NSLocalizedString(@"Rate Us", @"Title of rate us button on app store rating prompt")];
}
[alert show];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
仍然无法自定义GitHub中提供的代码。如果您已经在iOS应用中实现了它,请提供帮助。
答案 0 :(得分:1)
Apologies Swati&amp; Horizon_Net - SurveyMonkey iOS SDK尚未正式发布 - 它目前仅在私人测试版中提供。我是Android和iOS SDK的开发人员,很想得到您的反馈。因此,如果您想参加测试版,请填写this form.
我们会在SDK公开发布后更新此帖子,感谢您的耐心等待。