适用于 iOS 的 In-App 反馈(Instabug 的简化版)
microphone
和 photoLibrary
权限添加到 info.plist
<dict>
...
<key>NSMicrophoneUsageDescription</key>
<string>需要您的同意,才能访问麦克风</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>需要您的同意,才能访问相册</string>
...
</dict>
#import <SCFeedback/SCFeedbackManager.h>
[[SCFeedbackManager sharedManager] setupSendInfoBlock:^(UIViewController *editInfoController, NSArray<SCFbMediaInfo *> *dataArray, NSString *text) {
// Hey, do something here, such as to compress the images and upload the data
}];
您可以根据需要添加上面的代码,例如在
AppDelegate.m
或您自定义的文件中。
SCFbMediaInfo
是一个 ClassCluster
,您可以通过以下方式获取图像或视频 URL
// SCFbMediaInfo *info = dataArray[0];
UIImage *image = [info image];
NSURL *fileUrl = [info videoFileUrl];
您可以使用文件 SCFeedbackManager.h
中的属性和 API 进行一些自定义 —— 只需滚动到文件底部,您会发现更多 :)
您可以不添加任何内容,直接显示编辑信息控制器
[[SCFeedbackManager sharedManager] gotoEditWithMediaInfo:nil];
当您摇动设备时,将显示一个警告,如果想要禁用该警告,请按照以下代码进行操作:
[[SCFeedbackManager sharedManager] enableShake:NO];
您可以通过 [SCFeedbackManager sharedManager].screenRecorder
的属性和 API 以自定义的方式做些操作(设置视频的帧率,设置视频的输出 URL 等)
有一个协议可以在视频录制完成后获取视频文件 URL 和封面图像
[SCFeedbackManager sharedManager].delegate = self;
- (void)scFeedback:(SCFeedbackManager *)manager didSaveRecordingVideoUrl:(NSURL *)fileUrl coverImage:(UIImage *)coverImage {
}
您可以通过 [SCFeedbackManager sharedManager].audioManager
的属性和 API 进行一些自定义操作
如果您想自定义右上角按钮的下一步动作,请使用SCFeedbackDelegate
[SCFeedbackManager sharedManager].delegate = self;
- (void)scFeedback:(SCFeedbackManager *)manager didShowDrawerController:(SCDrawerViewController *)controller {
controller.isCustomNextStep = YES;
controller.completeBlock = ^(UIImage *image) {
// do something with the image
};
}
您可以通过这种方法来更改警报和textview的占位符文本
[SCFeedbackManager sharedManager].customInfo[scInfo_drawer_title] = @"Drawer title";
以下customInfo
的键可以用于更改文本(您可以在文件SCFeedbackManager.h
中找到它们)
extern NSString *const scInfo_drawer_title; // SCEditInfoViewController's title
extern NSString *const scInfo_editInfo_title; // SCEditInfoViewController's title
extern NSString *const scInfo_editInfo_placeholder; // SCEditInfoViewController, placeholder of textview
extern NSString *const scInfo_editInfo_beyondNumTitle; // SCEditInfoViewController, title of alert when the number of attachments is out of 4
extern NSString *const scInfo_editInfo_beyondNumMsg; // SCEditInfoViewController, message of alert when the number of attachments is out of 4
extern NSString *const scInfo_editInfo_beyondNumCancel; // SCEditInfoViewController, cancel button text of alert when the number of attachments is out of 4
extern NSString *const scInfo_shake_title; // title of alert after shaking
extern NSString *const scInfo_shake_msg; // message of alert after shaking
extern NSString *const scInfo_shake_capture; // capture button text of alert after shaking
extern NSString *const scInfo_shake_record; // record button text of alert after shaking
extern NSString *const scInfo_shake_closeShake; // close shaken button text of alert after shaking
extern NSString *const scInfo_shake_cancel; // cancel button text of alert after shaking
您可以像这样显示或隐藏右下角的覆盖按钮
// for in-app recording
[[SCFeedbackManager sharedManager] showOverlayBtnWithtype:SCFbOverlayTypeRecorder];
// for capture screen
[[SCFeedbackManager sharedManager] showOverlayBtnWithtype:SCFbOverlayTypeCapture];
// hide
[[SCFeedbackManager sharedManager] hideOverlayBtn];
默认路径是'Library/Caches/scrcd_{yyyyMMdd_HHmmss}.mp4'
,您可以使用属性更改路径
[[SCFeedbackManager sharedManager].screenRecorder.outputURL
.
您可以使用[SCFeedbackManager sharedManager]
的API显示所有视频和音频文件
/**
show the video saved in the sanbox
@param folder the files in the folder will be shown, if it is nil or empty, will find the default folder
*/
- (void)showFileListWithFolder:(NSString*)folder;
本代码在MIT许可的条款和条件下分发。