Desk360 iOS SDK
目录
摘要
Desk360 是一个 iOS SDK,帮助您轻松地将客户支持嵌入到您的 iOS 应用程序中!
功能
- 创建新的支持工单。
- 查看并评论现有的工单。
- 与相关支持团队进行交互式交流。
安装
使用 CocoaPods
要使用 CocoaPods 将 Desk360 集成到您的 Xcode 项目中,在您的 Podfile
中指定它。
pod 'Desk360'
使用 SPM
dependencies: [
.package(url: "https://github.com/Teknasyon-Teknoloji/desk360-ios-sdk", .branch("master"))
]
使用
重要脚注
您必须添加您的 info.plist 文件。
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow the app to access your photos.</string>
权限文本是可选的。您可以输入您想要的内容。但这个权限是必选的。如果您未添加此权限,Desk360 图像附件属性将不会工作。
使用 appId -以及一个可选的 deviceId 和一个可选的语言启动 Desk360-
注意:如果没有提供 deviceId,Desk360 将使用设备的 UUID,这可能会导致应用程序被删除时损失票据。如果使用环境类型 .production,Desk360 将查看 prod URL。如果没有提供应用程序语言,Desk360 将使用设备的语言。
import Desk360
let props = Desk360Properties(appKey: "1234")
// Or if you would like to provide more info here is a full list of the params
let props = Desk360Properties(
appKey: "1234",
deviceID: "34567",
environment: .production,
language: "en",
country: "TR",
userCredentials: .init(name: "John Doe", email: "[email protected]"),
bypassCreateTicketIntro: true,
hidePastTickets: false,
jsonInfo: ["a": 500, "b": "c"]
)
Desk360.start(using: props)
使用Desk360
import Desk360
class ExampleViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Desk360.show(on: self, animated: true)
}
}
使用可选通知系统
如果在用户收到消息时需要发送通知,您必须进行此集成。
import Desk360
@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Desk360.setPushToken(deviceToken: deviceToken)
}
}
完成上述集成后,您只需要在Desk360管理员面板中进行通知证书设置。现在您可以使用通知了
如果您想要通知重定向deeplink系统,您需要进行一些额外的集成。
import Desk360
@UIApplicationMain
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Desk360.applicationLaunchChecker(launchOptions)
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.delegate = self
}
return true
}
}
// MARK: - UNUserNotificationCenterDelegate
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert])
Desk360.willNotificationPresent(notification.request.content.userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Desk360.applicationUserInfoChecker(userInfo)
}
@available(iOS 10.0, *)
public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
Desk360.applicationUserInfoChecker(response.notification.request.content.userInfo)
}
}
当您在应用关闭时点击通知,您需要添加您希望Des360打开的页面的代码。
import Desk360
final class YourMainViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Desk360.showWithPushDeeplink(on: self)
}
}
获取未读工单
如果您想获取未读工单列表,您可以这样做
Desk360.getUnreadTickets { results in
switch results {
case .failure(let error):
print(error.localizedDescription)
case .success(let tickets):
print("Tickets: \(tickets.count)")
}
}
您可以根据应用程序的设计和体验展示未读工单。如果您想导航到特定的工单详情,您可以通过以下方式操作
let detailsViewController = Desk360.ticketDetailsViewController(ofTicket: unreadTicket)
self.present(detailsViewController, animated: true, completion: nil)
自定义Desk360主题
您应该使用Desk360仪表板来自定义配置。
支持
如果您有任何问题或功能请求,请创建一个问题。
许可证
Desk360在MIT许可证下发布。更多信息请参阅LICENSE。