BARK (Better App Reporting Kit) 是一个简单的 iOS 客户端应用程序问题报告库。摇晃应用程序会弹出一个操作表,其中测试用户可以立即发送电子邮件或创建 GitHub 问题 - 自动附加截图。
pod 'Bark', '~> 0.2'
或使用 git clone [email protected]:stagebloc/bark.git
克隆仓库MessageUI
- 用于在应用程序中发送电子邮件SystemConfiguration
- 用于网络可达性支持Security
- 用于安全存储 GitHub 凭据MobileCoreServices
- 用于在上传图片上的文件 MIME 类型检测AppDelegate.h
文件中,#import "SBBark.h"
,并将 <SBBarkDelegate>
添加到委托列表中。self.window
设置为 SBWindow 子类,如下所示 - 确保设置 bark.repositoryName
为要提交问题的仓库名称。#import "SBWindow.h"
...
// an example applicationdidFinishLaunchingWithOptions method
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// create an instance of the SBWindow subclass which will dispatch kSBWindowDidShakeNotification when window shake
SBWindow *window = [[SBWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// configure bark
SBBark *bark = [SBBark sharedBark];
bark.repositoryName = @"stagebloc/bark";
bark.delegate = self;
[[NSNotificationCenter defaultCenter] addObserverForName:kSBWindowDidShakeNotification
object:window
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
[bark showBark];
}];
self.window = window;
// Override point for customization after application launch.
SBRootViewController *rootViewController = [[SBRootViewController alloc] init];
self.window.rootViewController = rootViewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
最后,实现下面的 shouldShowActionSheet
方法。要始终在摇晃时显示操作表,请返回 YES
,或添加您自己的自定义逻辑。
- (BOOL)shouldShowActionSheet
{
/* add the logic to determine whether or not to show the action sheet. Something like:
if([currentUser isAdmin]) {
return YES;
} else return NO;
*/
return YES;
}
BARK 带有一系列功能,可用于快速调整。您可以在 bark
对象的以下 repositoryName
中设置这些。
// email
bark.emailRecipients = @[@"[email protected]", @"[email protected]"];
bark.emailSubject = @"Subject";
bark.emailBody = @"Body"; // note that this will override sending device info
bark.attachScreenshot = YES; // defaults to YES
// github
bark.defaultAssignee = @"your_username";
bark.defaultMilestone = @"milestone_title";
bark.attachDeviceInfo = YES; // defaults to YES
BARK也可以使用 SBBark
单例在应用程序的任何地方按程序方式显示
[[SBBark sharedBark] showBark];
可以通过自定义 shouldShowActionSheet
方式在生产中使用 BARK。您需要创建自己的方式来确定当前用户是否是管理员。请查看下面的示例 - 我们检查登录用户电子邮件地址。
- (BOOL)shouldShowActionSheet
{
NSArray *adminEmails = @[@"[email protected]", @"[email protected]"];
for(NSString *email in adminEmails) {
if([email isEqualToString:[[self getLoggedInUser] email]]) {
return YES;
}
}
return NO;
}
BARK 根据 MIT 许可证 (MIT) 发布
版权(c)2013 StageBloc
hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
本软件按“原样”提供,不提供任何保修,无论是明示保修还是暗示性保修,包括但不限于针对适销性、针对特定目的的适用性和非侵犯性的保证。在任何情况下,作者或版权所有者不对任何主张、损害或其他责任负责,无论这些责任源于合同行为、侵权或其他原因,以及与软件或对软件的使用或其他与之相关的处理。