NPCricket 0.1.8

NPCricket 0.1.8

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2017

Maintained by Nebojsa Petrovic.



NPCricket 0.1.8

NPCricket

CI Status
Version
License
Platform

About

Cricket is an iOS library for sending feedback from within your app.

Typical Scenario:

  1. Alice wants to leave feedback. She shakes her phone.
  2. Cricket grabs a screenshot of the current screen.
  3. Alice draws a rectangle around a button she doesn't like.
  4. She writes "I hate buttons!"
  5. Cricket attaches the annotated screenshot to an email and Alice sends it.

GitHub Logo

Hello Cricket

#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];
    }
}

Overview

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)

Creating Handlers

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];

Requirements

Cricket requires iOS 8.0 and above.

Installation

NPCricket is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "NPCricket"

Author

Nebojsa Petrovic, [email protected]

License

NPCricket is available under the MIT license. See the LICENSE file for more info.