Inventiv Critic iOS Library
Use this library to add Inventiv Critic to your iOS app.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
- Add the Critic pod to your
Podfile
.
pod 'Critic'
- Find your Product Access Token in the Critic Web Portal by viewing your Product's details.
- Initialize Critic by starting it from your
AppDelegate
.
// Swift
Critic.instance().start("YOUR_PRODUCT_ACCESS_TOKEN")
// Objective-C
[[Critic instance] start:@"YOUR_PRODUCT_ACCESS_TOKEN"];
Configuration
Shake to Send Feedback Report
By default, Critic will prompt your users for feedback when they shake their device. You can disable this if desired.
// Swift
Critic.instance().preventShakeDetection()
// Objective-C
[[Critic instance] preventShakeDetection];
Log Capture
By default, devices that are not connected to a debug session will pipe console output (stderr
and stdout
) to a log file, which is
included with submitted Reports. You can disable this behavior prior to starting Critic.
// Swift
Critic.instance().preventLogCapture()
// Objective-C
[[Critic instance] preventLogCapture];
If you are running a simulator and want to capture logs from the console, you can explicitly start log capture yourself.
// Swift
Critic.instance().startLogCapture()
// Objective-C
[[Critic instance] startLogCapture];
Sending Customer Feedback Reports
You can show the default feedback report screen any time you like by calling the following method from a UIViewController
.
// Swift
Critic.instance().showDefaultFeedbackScreen(self)
// Objective-C
[[Critic instance] showDefaultFeedbackScreen:self];
Change Text on Default Feedback Screens.
The text shown on the default feedback report screen and the shake detection dialog can be customized to your liking.
// Swift
Critic.instance().setDefaultShakeNotificationTitle("Easy, easy!")
Critic.instance().setDefaultShakeNotificationMessage("Do you want to send us feedback?")
Critic.instance().setDefaultFeedbackScreenTitle("Submit Feedback")
Critic.instance().setDefaultFeedbackScreenDescriptionPlaceholder("What's happening?\n\nPlease describe your problem or suggestion in as much detail as possible. Thank you for helping us out! 🙂");
// Objective-C
[[Critic instance] setDefaultShakeNotificationTitle:@"Easy, easy!"];
[[Critic instance] setDefaultShakeNotificationMessage:@"Do you want to send us feedback?"];
[[Critic instance] setDefaultFeedbackScreenTitle:@"Submit Feedback"];
[[Critic instance] setDefaultFeedbackScreenDescriptionPlaceholder:@"What's happening?\n\nPlease describe your problem or suggestion in as much detail as possible. Thank you for helping us out! 🙂"];
Sending Product-Specific Metadata with Reports
You can add product-specific metadata through adding entries to the Critic.instance().productMetadata
dictionary.
// Swift
Critic.instance().productMetadata["email"] = "[email protected]"
// Objective-C
[[[Critic instance] productMetadata] setObject:@"[email protected]" forKey:@"email"];
Sending Device-Specific Metadata
You can add device-specific metadata through adding entries to the Critic.instance().deviceMetadata
dictionary.
// Swift
Critic.instance().deviceMetadata["device_uuid"] = "abc123"
// Objective-C
[[[Critic instance] deviceMetadata] setObject:@"abc123" forKey:@"device_uuid"];
Be sure to set your metadata values prior to calling Critic.instance().start()
if you wish to include the metadata with every device ping.
Metdata added after starting will only be added to bug report submissions.
Customizing Feedback Reports
Use the NVCReportCreator
to build your own reports for custom user experiences or other use cases. Perform NVCReportCreator
work on a background thread.
// Swift
let reportCreator = NVCReportCreator()
reportCreator.description = "This is user-entered text about the idea or experience they wish to report."
reportCreator.metadata["Whatever key you want"] = "Whatever value you want"
reportCreator.attachmentFilePaths.add("/absolute/path/to/desired/file.txt")
reportCreator.create({(success: Bool, error: Error?) in
if success {
NSLog("Feedback has been submitted!")
}
else {
NSLog("Feedback submission failed.")
}
})
// Objective-C
NVCReportCreator *reportCreator = [NVCReportCreator new];
reportCreator.description = @"This is user-entered text about the idea or experience they wish to report.";
[report.metadata setObject:@"Whatever value you like" forKey:@"Whatever key you want"];
[report.attachmentFilePaths addObject:@"/absolute/path/to/desired/file.txt"];
[reportCreator create:^(BOOL success, NSError *error){
if(success){
NSLog(@"Feedback has been submitted!");
} else {
NSLog(@"Feedback submission failed.");
}
}];
Viewing Feedback Reports
Visit the Critic web portal to view submitted reports. Below is some of the device and app-specific information included with every iOS report.
License
This library is released under the MIT License.