iOS documentation

Basics

Doorbell requires iOS 9 or newer.

You can include Doorbell via CocoaPods or Swift Package Manager:

In the ViewController where you want to use Doorbell, you'll need to import the library using:

Swift
import Doorbell

Make sure you have use_frameworks! in your Podfile

Objective C
#import "Doorbell/Doorbell.h"

Attributes/Methods

There are 7 attributes that you can set on the Doorbell object: NSString *email, NSString *name, BOOL screenshot, BOOL nps, BOOL showEmail, BOOL animated, and BOOL showPoweredBy.

There are 5 methods that you can call on the Doorbell object: (id)initWithApiKey:(NSString *)apiKey appId:(NSString *)appID, (Doorbell*)doorbellWithApiKey:(NSString *)apiKey appId:(NSString *)appID, (void)addPropertyWithName:(NSString*)name AndValue:(id)value;, (void)showFeedbackDialogInViewController:(UIViewController *)vc completion:(DoorbellCompletionBlock)completion, and (void)submitFeedback:(NSString*)message email:(NSString*)email completion:(DoorbellCompletionBlock)completion.

Example (Swift)


    // In your ViewController
    let appId = "YOUR-ID-GOES-HERE"
    let appKey = "KEY"

    let feedback = Doorbell.init(apiKey: appKey, appId: appId)

    // Pre-populate the email field if you know the email address
    feedback!.email = "hello@doorbell.io";

    // If we know the email address, we can set this to NO
    feedback!.showEmail = YES;

    // Set the name of the user if you know it, so you can see it in Doorbell
    feedback!.name = @"Philip";

    // If you want the dialog to animate when it appears
    feedback!.animated = YES;

    // Automatically attach a screenshot of the screen with the feedback
    feedback!.screenshot = YES;

    // Allow users to submit an NPS rating along with their feedback
    feedback!.nps = YES;

    // Add custom properties/metadata
    feedback!.addProperty(withName: "username", andValue: "manavo")
    feedback!.addProperty(withName: "account_id", andValue: 1234)

    // Add tags with each message
    feedback!.tags.addObject("tag1");
    feedback!.tags.addObject("tag2");

    feedback!.showFeedbackDialog(in: self, completion: { (error, cancelled) -> Void in
        if (error?.localizedDescription != nil) {
            print(error!.localizedDescription);
        }
    })
            

Example (Objective C)


    // In your ViewController
    NSString *appId = @"YOUR-ID-GOES-HERE";
    NSString *appKey = @"KEY";

    Doorbell *feedback = [Doorbell doorbellWithApiKey:appKey appId:appId];

    // Pre-populate the email field if you know the email address
    feedback.email = @"hello@doorbell.io";

    // If we know the email address, we can set this to NO
    feedback.showEmail = YES;

    // Set the name of the user if you know it, so you can see it in Doorbell
    feedback.name = @"Philip";

    // If you want the dialog to animate when it appears
    feedback.animated = YES;

    // Automatically attach a screenshot of the screen with the feedback
    feedback.screenshot = YES;

    // Allow users to submit an NPS rating along with their feedback
    feedback.nps = YES;

    // Add custom properties/metadata
    [feedback addPropertyWithName:@"username" AndValue:@"manavo"];
    [feedback addPropertyWithName:@"account_id" AndValue:[NSNumber numberWithInt:1234]];

    // Add tags with each message
    [feedback.tags addObject:@"tag1"];
    [feedback.tags addObject:@"tag2"];

    [feedback showFeedbackDialogInViewController:self completion:^(NSError *error, BOOL isCancelled) {
        if (error) {
            NSLog(@"%@", error.localizedDescription);
        }
    }];
            

Example (Swift UI)


    // In your View, define a button or something to trigger the feedback dialog
    Button(action: feedback) {
        Label("Feedback", systemImage: "plus")
    }

    // In the same struct, create a function that can be called to initialize Doorbell
    private func feedback() {
        var currentKeyWindow: UIWindow? {
          UIApplication.shared.connectedScenes
            .filter { $0.activationState == .foregroundActive }
            .map { $0 as? UIWindowScene }
            .compactMap { $0 }
            .first?.windows
            .filter { $0.isKeyWindow }
            .first
        }

        var rootViewController: UIViewController? {
          currentKeyWindow?.rootViewController
        }

        let appId = "YOUR-ID-GOES-HERE"
        let appKey = "KEY"

        let feedback = Doorbell.init(apiKey: appKey, appId: appId)

        feedback!.showFeedbackDialog(in: rootViewController, completion: { (error, cancelled) -> Void in
            if (error?.localizedDescription != nil) {
                print(error!.localizedDescription);
            }
        })
    }

            

Shake gesture

You can configure Doorbell to be shown when the device is shaken.

You can either configure it application-wide, to show on any ViewController, or only on specific ViewControllers

Example (Swift)


    let appId = "YOUR-ID-GOES-HERE"
    let appKey = "KEY"

    // In your AppDelegate, add this to application:didFinishLaunchingWithOptions method
    // and it will show on any ViewController
    let feedback = Doorbell.init(apiKey: appKey, appId: appId)
    feedback!.startShakeListener({ (error, _unused) -> Void in
        if (error?.localizedDescription != nil) {
            print(error!.localizedDescription);
        }
    })

    // In your specific ViewController, add this to the viewDidLoad method
    let feedback = Doorbell.init(apiKey: appKey, appId: appId)
    feedback!.startShakeListener(with: self, completion: { (error, _unused) -> Void in
        if (error?.localizedDescription != nil) {
            print(error!.localizedDescription);
        }
    })

Example (Objective C)


    NSString *appId = @"YOUR-ID-GOES-HERE";
    NSString *appKey = @"KEY";

    // In your AppDelegate, add this to application:didFinishLaunchingWithOptions method
    // and it will show on any ViewController
    Doorbell *feedback = [Doorbell doorbellWithApiKey:appKey appId:appId];
    [feedback startShakeListener:^(NSError *error, BOOL isCancelled) {
            if (error) {
                NSLog(@"%@", error.localizedDescription);
            } else if (isCancelled) {
                NSLog(@"Dialog was cancelled");
            } else {
                NSLog(@"Dialog was successfully submitted");
            }
    }];

    // In your specific ViewController, add this to the viewDidLoad method
    Doorbell *feedback = [Doorbell doorbellWithApiKey:appKey appId:appId];
    [feedback startShakeListenerWithViewController:self completion:^(NSError *error, BOOL isCancelled) {
            if (error) {
                NSLog(@"%@", error.localizedDescription);
            } else if (isCancelled) {
                NSLog(@"Dialog was cancelled");
            } else {
                NSLog(@"Dialog was successfully submitted");
            }
    }];

Using your own form

You might want to use your own form to capture the feedback, and send it to Doorbell.

Doorbell makes this easy by allowing you to submit messages using the SDK:

Example (Swift)


    // In your ViewController
    let appId = "YOUR-ID-GOES-HERE"
    let appKey = "KEY"

    let feedback = Doorbell.init(apiKey: appKey, appId: appId)

    feedback!.submitFeedback("Your message", email: "email@example.com", completion: { (error, _unused) -> Void in
        if (error?.localizedDescription != nil) {
            print(error!.localizedDescription);
        }
    })
            

Example (Objective C)


    // In your ViewController
    NSString *appId = @"YOUR-ID-GOES-HERE";
    NSString *appKey = @"KEY";

    Doorbell *feedback = [Doorbell doorbellWithApiKey:appKey appId:appId];

    [feedback submitFeedback:@"Your message" email:@"email@example.com" completion:^(NSError *error, BOOL _unused) {
        if (error) {
            NSLog(@"%@", error.localizedDescription);
        } else {
            NSLog(@"Feedback was successfully submitted");
        }
    }];