RepliesSDK-macOS 0.3.7

RepliesSDK-macOS 0.3.7

许可证 MIT
发布最新发布2020年8月

Replies 团队 维护。



  • Replies 团队

RepliesSDK-macOS

这是一个框架,可以将 replies.io 直接嵌入到您的 Mac 应用程序中。需要macOS 10.9或更高版本。

它是如何工作的

该框架将下载您的建议并在匹配用户输入的关键词和用户输入的语言时,将它们展示给用户。用户的语言将在用户键入时由macOS检测。

如果提供了 supportedLanguages,当未找到用户语言的建议时,建议将回退到您提供的第一种语言。

基本示例

# import <RepliesSDK/RepliesSDK.h>

[[RepliesIO sharedReplies] setAPIHost:@"1b.replies.io"]; // required
[[RepliesIO sharedReplies] setProductName:@"ProductName"]; // required
[[RepliesIO sharedReplies] setFormIdentifier:@"xxx"]; // required
[[RepliesIO sharedReplies] setSubjectTypes:@[RepliesIOSubjectProblem,RepliesIOSubjectFeatureRequest]]; // optional
[[RepliesIO sharedReplies] setSupportedLanguages:@[@"en",@"de"]]; // optional
[[RepliesIO sharedReplies] setMetaData:@{@"type":@"Test"}]; // optional
[[RepliesIO sharedReplies] setDelegate:self]; // optional
[[RepliesIO sharedReplies] presentWindow:self]; // showing the actual window
[[RepliesIO sharedReplies] setCustomWindowTitle:@"Get Help"]; // optional

APIHost

请使用在 Replies/Settings/Channels 中提供的主机。

ProductName

请使用在 Replies/Settings/Products 中设置的其中一个产品。

FormIdentifier

您可以从 Replies/Settings/Channels 获取这个标识符。

SubjectTypes

您可以自由提供任何 NSStrings 的 NSArray 作为主题。内置的常量将由框架的语言本地化。

RepliesIOSubjectProblem = @"Problem";
RepliesIOSubjectFeatureRequest = @"Feature Request";
RepliesIOSubjectTestimonial = @"Testimonial";
RepliesIOSubjectOther = @"Other";
RepliesIOSubjectQuestion = @"Question";
RepliesIOSubjectInquiry = @"Inquiry";

附件

除了用户可以添加的附件外,您还可以以编程方式添加附件。用户将看到一个附件列表,并且可以删除它们。

[RepliesIOAttachment attachmentWithPath:aPath];
[RepliesIOAttachment attachmentWithData:aData fileName:@"Test.plist"];
[RepliesIOAttachment attachmentWithString:@"Hello World" fileName:@"Text.txt"];
[RepliesIOAttachment attachmentWithApplicationLog]; // Console log is gathered asyncronous
[RepliesIOAttachment attachmentWithPropertyList:aDictionary]; // Ends up as JSON File

元数据

使用元数据,您可以使用 NSStrings 提供的 NSDictionary 添加有关您产品的额外数据。请尊重用户的隐私。在可能的情况下使用附件。

NSMutableDictionary * aDictionary = [NSMutableDictionary dictionary];
[aDictionary setValue:[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleVersion"] forKey:@"version"];
[[RepliesIO sharedReplies] setMetaData:aDictionary];

SupportedLanguages

如果您提供了一个包含语言代码的 NSArray,Replies 将向用户指示您只能在这些语言中提供支持。然而,用户可以随意发送他们想要的任何垃圾信息。

[[RepliesIO sharedReplies] setSupportedLanguages:@[@"en",@"fr",@"jp"]];

菜单

可以添加一个菜单与常规文件附加/截图按钮并排。虽然这个菜单可以包含任何功能,但您应该只为创建附件而使用它。

NSMenu * aMenu = [[NSMenu alloc] initWithTitle:@""];
[aMenu addItemWithTitle:@"Preferences" action:@selector(attachPreferences:) keyEquivalent:@""];
[[RepliesIO sharedReplies] setMenu:aMenu];


-(void)attachPreferences:(id)sender
{
    NSDictionary * aInfo = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
    NSData * aData = [NSPropertyListSerialization dataWithPropertyList:aInfo format:NSPropertyListXMLFormat_v1_0 options:nil error:nil];
    RepliesIOAttachment * attachment = [RepliesIOAttachment attachmentWithData:aData fileName:@"Preferences.plist"];
    [[RepliesIO sharedReplies] addAttachment:attachment];
}

可用的委托方法

-(void)repliesWillPresentWindow:(RepliesSDK *)replies;
-(void)repliesDidPresentWindow:(RepliesSDK *)replies;
-(void)replies:(RepliesSDK *)replies willSendMessage:(RepliesIOMessage *)message;
-(void)replies:(RepliesSDK *)replies didSendMessage:(RepliesIOMessage *)message;
-(void)replies:(RepliesSDK *)replies userDidVoteForSuggestion:(NSDictionary *)suggestion;

委托示例

-(void)replies:(RepliesSDK *)replies didSendMessage:(RepliesIOMessage *)message
{
    RepliesIOConfirmationAlert * aAlert = [RepliesIOConfirmationAlert alertWithMessage:message];
    aAlert.informativeText = @"Thank you for contacting support.";
    [aAlert runModal];
}