Parameter error when submitting feedback
Problem description
A parameter error occurs when you submit feedback:
Problem analysis
This error usually occurs because the AppKey and AppSecret parameters are incorrect.
Solution
Verify the values by comparing them with your server-side data. For example, the AppKey or AppSecret in your project might not match the one in the console.
If the values are correct, check for memory issues. The network request might not be sent to the server-side if the
YWFeedbackKitobject is released prematurely.For Android, upgrade to version 3.3.1 and test the feedback submission again.
The following example illustrates the second scenario.
A user might open the feedback page with the following code:
- (void)viewDidLoad {
[super viewDidLoad];
FeedbackHelper *helper = [FeedbackHelper new];
[helper openFeedbackViewController];
}
The FeedbackHelper contains the following logic:
@interface FeedbackHelper ()<UISplitViewControllerDelegate>
@property (nonatomic, strong) YWFeedbackKit *feedbackKit;
@end
- (YWFeedbackKit *)feedbackKit {
if (!_feedbackKit) {
_feedbackKit = [[YWFeedbackKit alloc] initWithAppKey:kAppKey appSecret:kAppSecret];
}
return _feedbackKit;
}
/** Opens the user feedback page */
- (void)openFeedbackViewController {
[self.feedbackKit makeFeedbackViewControllerWithCompletionBlock:^(YWFeedbackViewController *viewController, NSError *error) {
if (viewController != nil) {
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
[ [ViewController getInstance] presentViewController:nav animated:YES completion:nil];
[viewController setCloseBlock:^(UIViewController *aParentController){
[aParentController dismissViewControllerAnimated:YES completion:nil];
}];
} else {
/** Comment out this section if you use a custom method to throw the error. */
NSString *title = [error.userInfo objectForKey:@"msg"]?:@"The API call failed. Please ensure your network connection is stable.";
NSLog(@"%@", title);
}
}];
}
When the page opens, the helper object is released, which also releases the self.feedbackKit object. As a result, the AppKey and AppSecret properties are also released, causing a parameter error when the network request is sent.
Change the setting to the following:
FeedbackHelper *helper = [FeedbackHelper sharedInstance];
[helper openFeedbackViewController];
Alternatively, set FeedbackHelper *helper as a property:
@interface ViewController ()
@property (nonatomic, strong) FeedbackHelper *helper;
@end
- (void)viewDidLoad {
[super viewDidLoad];
self.helper = [FeedbackHelper new];
[helper openFeedbackViewController];
}
This prevents the FeedbackKit object from being released, which ensures that the AppKey and AppSecret values are not released from memory prematurely. As a result, subsequent network requests do not cause parameter errors.