Skip to content

Instantly share code, notes, and snippets.

View baz8080's full-sized avatar

Barry Carroll baz8080

  • Pinterest
  • Dublin
View GitHub Profile
@baz8080
baz8080 / Rollbar.kt
Created March 29, 2021 20:20
How to use self hosted Rollbar instance in Android SDK
Rollbar.init(this, "{access_token}", "production", true, true)
val rollbar = Rollbar.instance()
val originalConfig = rollbar.config()
val id = 123
// There's essential config in the default 'originalConfig', so start from that.
val config = ConfigBuilder.withConfig(originalConfig)
.endpoint("https://{self_hosted_domain}/api/1/item/")
.sender(null) // working around a bug in their builder. tested version: 1.7.5
@baz8080
baz8080 / AndroidManifest.xml
Created December 15, 2020 13:44
Workaround for the bug where the conversations icon disappears sometimes.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:name=".MainApplication"
...
android:theme="@style/AppTheme">
<!-- Remember to declare the CustomHelpCenterActivity -->
let model = ZDKHelpCenterOverviewContentModel.defaultContent()
// Use the model to filter content by IDs, tags, etc
ZDKHelpCenterProvider().getHelpCenterOverview(withHelpCenterOverviewModel: model) { (result, _) in
guard let categories = result else { return }
print ("Help Center has \(categories.count) categories")
for category in categories {
@baz8080
baz8080 / ClearlyOpaque.swift
Created May 27, 2020 16:07
Workaround for "gap" when using opaque UINavigatonBar color and Zendesk Support on iOS 13+
let requestConfig = RequestUiConfiguration()
let helpCenter = HelpCenterUi.buildHelpCenterOverviewUi(withConfigs: [requestConfig])
// Workaround when using an opaque UINavigationBar with a tint
helpCenter.extendedLayoutIncludesOpaqueBars = true;
self.navigationController?.pushViewController(helpCenter, animated: true)
@baz8080
baz8080 / AddCloseButton.swift
Created May 21, 2020 11:40
Adding a close button when presenting a Unified SDK ViewController modally
private var backButton: UIBarButtonItem {
let barButtonItem = UIBarButtonItem(title: "Dismiss", style: .plain, target: self, action: #selector(dismissViewController))
if #available(iOS 13, *) {
barButtonItem.image = UIImage(systemName: "xmark")
}
return barButtonItem
}
@objc private func dismissViewController() {
navigationController?.dismiss(animated: true, completion: nil)
@baz8080
baz8080 / NavBarStyle.swift
Created May 21, 2020 11:35
NavigationBar styling
// Zendesk SDK ViewController inherit the style from your NavigationController.
// This code shows how to set those properties so they are inherited by Zendesk.
// Back button
navigationController?.navigationBar.tintColor = .black
// Title
let textAttributes = [NSAttributedString.Key.foregroundColor: UIColor.blue]
navigationController?.navigationBar.titleTextAttributes = textAttributes
@baz8080
baz8080 / GetId.swift
Created May 21, 2020 11:29
Getting the Request ID from a newly created request
let createRequest = ZDKCreateRequest()
createRequest.subject = "Hello?"
createRequest.requestDescription = "Is it me you're looking for?"
let requestProvider = ZDKRequestProvider()
requestProvider.createRequest(createRequest) { (response, error) in
if (error != nil) {
// Display / Handle the error
return
@baz8080
baz8080 / TicketForm.swift
Created April 30, 2020 15:18
Setting ticket form ID
// Create object
let request = ZDKCreateRequest()
// Set mandatory properties
request.subject = "Hello Provider"
request.requestDescription = "Description"
// Specify which form to use
request.ticketFormId = 1234;
@baz8080
baz8080 / SnackbarLessPain.kt
Last active July 25, 2017 21:11
Snackbar testing: the less crap version
@Test
fun genericErrrorSnackbarShouldHaveExpectedText() {
// Same setup as previous example - omitting
// Simple tests same as previous example - omitting
val snackbarLayout = snackbar.view
// Now we can use standard findViewById
val snackbarTextView = snackbarLayout.findViewById<TextView>(R.id.snackbar_text)
assertThat(snackbarTextView).isNotNull()
@baz8080
baz8080 / snackbar_layout.xml
Created July 25, 2017 21:01
Snackbar layout
<view
class="android.support.design.internal.SnackbarContentLayout"
>
<TextView
android:id="@+id/snackbar_text"/>
<Button
android:id="@+id/snackbar_action"
android:visibility="gone"/>