Skip to content

nebs/NPCricket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ DEPRECATED ⚠️

NPCricket has been deprecated and is no longer supported. Consider using the new Cricket instead (re-written in Swift).

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.