Built-in screens
CrmSdk on its own draws nothing: your app reads its state and draws every screen. If you’d rather not, add CrmSdkUI, the SDK’s built-in screens, written in UIKit. They open over your app the way a support messenger usually does: the messenger and its conversations in a sheet, and your in-app messages as banners, sheets and cards.
You can use them for everything, for some places only, or not at all.
Add the built-in screens
Section titled “Add the built-in screens”-
In Xcode, open your target’s General › Frameworks, Libraries, and Embedded Content, and add the CrmSdkUI library from the same package as
CrmSdk. It runs on iOS 13 and later, and has no dependencies of its own. -
Install it once, after you’ve made the
Crm, set its host and started it:AppDelegate.swift import CrmSdkimport CrmSdkUIcrm.start()CrmUI.install(crm)
That’s all. From now on, every way into PurrCRM‘s pages opens the built-in screen: crm.open(...), a tapped push, a link, and the setup check.
Open a screen yourself
Section titled “Open a screen yourself”Call these from a button in your app:
CrmUI.current?.presentMessenger() // the messenger's first screenCrmUI.current?.presentNewConversation() // a new conversation, ready to type inCrmUI.current?.presentConversation(id) // one conversationCrmUI.current?.presentHelpCenter() // the help center, with its searchCrmUI.current?.presentCollection(slug) // one collection of articlesCrmUI.current?.presentArticle(slug) // one articleCrmUI.current?.presentTickets() // the signed-in user's ticketsCrmUI.current?.presentTicket(id) // one ticketCrmUI.current?.presentPreferences() // which messages they get, and howCrmUI.current?.presentInbox() // the notices you sent them, newest firstCrmUI.current?.dismiss() // close them all, back to your appThe inbox has no link of its own, so open it from your app, from a bell for example. It needs someone signed in: presentInbox() returns false otherwise.
Show a message by its id
Section titled “Show a message by its id”To show one carousel, survey or post at a moment of your choosing (after a purchase, say), call it by its id. The id is on the message’s page on PurrCRM.
CrmUI.current?.presentCarousel(id) // a carousel your team madeCrmUI.current?.presentSurvey(id) // a surveyCrmUI.current?.presentPost(id) // a postCrmUI.current?.presentMessage(id) // any in-app message, whatever its kindThe SDK asks PurrCRM for that message and shows it next, even if no check-in brought it. It still waits until you call crm.setReady(true), and nothing shows if the message isn’t meant for the signed-in user.
The message must be set to show Only when its link is opened on PurrCRM. A message that shows on its own when people check in can’t be called up by its id.
In-app messages
Section titled “In-app messages”With the built-in screens installed, your in-app messages come in over your app as they arrive:
- a banner slides in across the top, without moving your layout. A tap anywhere else still reaches your screen, and people swipe it away;
- a post, a survey or a carousel opens as a sheet, a card or the whole screen, as your team chose on PurrCRM.
They still wait until you call crm.setReady(true), so they never cover your sign-in or onboarding steps. Everything people do with them is reported to PurrCRM as usual.
The screens are drawn in a window of their own, above your app’s and below its alerts. Your app’s own screens and navigation stay as they are.
Choose what is built in
Section titled “Choose what is built in”Pass CrmUIOptions to install:
CrmUI.install( crm, options: CrmUIOptions( places: [.messenger, .conversation, .newConversation], presentMessages: true, theme: CrmUITheme(accent: UIColor(red: 0.06, green: 0.46, blue: 0.43, alpha: 1)), launcher: .site ))places: the pages the SDK draws. A page you leave out goes to your ownCrmHost.navigate, as it would without the built-in screens.presentMessages: set it tofalseto draw your in-app messages yourself (see In-app messages) while the SDK draws the messenger.theme: the accent colour, light or dark (darkMode), the fonts, the corners (corner), the buttons’ shape (buttonShape) and the animation (motion). Leave a part out and it comes from the look your team published (see below).launcher: whether the launcher shows:.site(as your team chose, the default),.alwaysor.never.imageLoader: your own picture loader, if your app already has one.
Set crm.host before you install: a host you set afterwards replaces the built-in screens’ navigation.
The look from PurrCRM
Section titled “The look from PurrCRM”Your team can style the built-in screens on PurrCRM, under Settings › your app › Messenger: the colours, the corners and buttons, light or dark, the messenger’s header and words, the launcher, and the animation (see Style the messenger and messages). The screens follow it the next time the app opens, with no new release.
Anything you set in code wins. Each part of the look comes from, in order:
- your
theme, where you set that part; - the look your team published on PurrCRM;
- the SDK’s own default.
So CrmUITheme(accent: …) keeps your accent and takes everything else from PurrCRM. When the phone is set to Reduce Motion, nothing animates, whatever the look or your theme says.
The launcher
Section titled “The launcher”When your team turns the launcher on, a round button floats over your app’s screens. It opens the messenger and shows how many messages are unread. It puts itself away while the messenger, a message or the keyboard is up, and never shows over PurrCRM‘s own screens.
To keep it off one of your screens, a full-screen video say:
CrmUI.current?.hideLauncher() // in viewWillAppearCrmUI.current?.showLauncher() // in viewWillDisappearPut a screen in your own navigation
Section titled “Put a screen in your own navigation”The messenger’s screens are public view controllers too, to push in your own navigation controller:
navigationController?.pushViewController(CrmMessengerViewController(crm: crm), animated: true)Change the words
Section titled “Change the words”The screens’ words are in a strings table called CrmSdkUI, in English. To word one differently, or to add a language, add a CrmSdkUI.strings file to your app with the same keys: your app’s words win, key by key.