NPCricket has been deprecated and is no longer supported. Consider using the new Cricket instead (re-written in Swift).
Cricket is an iOS library for sending feedback from within your app.
- Alice wants to leave feedback. She shakes her phone.
- Cricket grabs a screenshot of the current screen.
- Alice draws a rectangle around a button she doesn't like.
- She writes "I hate buttons!"
- Cricket attaches the annotated screenshot to an email and Alice sends it.
#import <NPCricket/NPCricket.h>
#import <NPCricket/NPNativeEmailHandler.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NPNativeEmailHandler *nativeEmailHandler = [NPNativeEmailHandler handlerWithToEmailAddress:@"[email protected]"];
[NPCricket useHandler:nativeEmailHandler];
// ... your code here ...
return YES;
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (motion == UIEventSubtypeMotionShake) {
[NPCricket show];
}
}
Cricket does not show itself automatically. Instead, you must call [NPCricket show]
yourself. The example above uses a shake gesture to trigger Cricket. It also sends the feedback via email. You can customize and configure both of these things to your liking.
Cricket uses "handlers" to process feedback. Any class can become a handler by conforming to the NPCricketHandler
protocol. An example of a custom handler could be something that sends feedback directly to your server.
For your convenience I've included a handler for using the built-in email composer (NPNativeEmailHandler
)
If you want to create your own handler simply create a class that conforms to NPCricketHandler
and implement the single method, like so:
#import "NPCricketHandlerProtocol.h"
@interface MyCustomHandler : NSObject <NPCricketHandler>
@end
@implementation MyCustomHandler
- (void)NPCricket_handleFeedback:(NPFeedback *)feedback {
// Do something with the feedback ...
}
@end
Don't forget to tell NPCricket
to use your handler.
MyCustomHandler *myCustomHandler = [[MyCustomHandler alloc] init];
[NPCricket useHandler:myCustomHandler];
Cricket requires iOS 8.0 and above.
NPCricket is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "NPCricket"
Nebojsa Petrovic, [email protected]
NPCricket is available under the MIT license. See the LICENSE file for more info.