iOS
Pre-requisites
- ASAPP iOS SDK 9.4.0 or later, correctly configured and initialized see more here.
Getting Started
Once you’ve successfully configured and initialized the ASAPP SDK, you can start using Chat Instead for iOS.
-
Create a New Instance.
phoneNumber (required) The phone number to call when the phone channel is selected. Must be a valid phone number. For more information, see Apple’s documentation on phone links. delegate (required) An object that implements ASAPPChannelDelegate
.title (optional) A title (also called the “Chat Instead header title”) which is displayed at the top of the Chat Instead UI. (See Customization) image (optional) A UI Image that will override the default image for the chat channel. (See Customization) -
Implement two functions that the
ASAPPChannelDelegate
requires:This is called if there’s an error while trying to open a channel.
This opens the ASAPP chat.
You should use one of these methods:
or
to present or push the view controller instance that was returned.
This means that you must present/push the ASAPP chat view controller inside
didSelectASAPPChatChannel()
.
ASAPP highly recommends initializing ASAPPChatInsteadViewController
as early as possible for the best user experience.
Whenever a channel is selected, ASAPP handles everything by default (except for the chat channel), but you can also handle a channel by yourself by implementing func shouldOpenChannel(_ channel: ASAPPChannel) -> Bool
and returning false.
-
Show the
chatInsteadViewController
instance by using:
Only presentation is supported. Pushing the chatInsteadViewController
instance is not supported and will result in unexpected behavior.
Support for iPad
For the best user experience, you should configure popover mode, which is used on iPad.
Use the .popover
presentation style and set both the sourceView and sourceRect properties following Apple’s conventions:
This will only have an effect when your app is run on iPad.
If you set modalPresentationStyle
to .popover
and forget to set sourceView
and sourceRect
, the application will crash in runtime. So please be sure to set both if you’re using the popover mode.
Customization
You can customize the Chat Instead header title and the chat icon when creating the ASAPPChatInsteadViewController
instance. (ee Getting Started.
ASAPPChatInsteadViewController
uses ASAPPColors for styling, so it will automatically use the colors set there (e.g. primary
, background
, onBackground
, etc.), which are the same colors used for customizing the ASAPP chat interface. There is no way to independently change the styling of the Chat Instead UI.
ASAPP supports Dark Mode by default as long as you enable it.
Remote settings
When you create an instance of ASAPPChatInsteadViewController
, it will automatically fetch remote settings to indicate which channels to display. You can configure these settings.
These remote settings will override local ones (i.e. the ones you pass in when creating the ASAPPChatInsteadViewController
instance).
If there’s an error while fetching the settings and no local values were set, the defaults will be used.
Cache
When fetching succeeds, the SDK will cache the remote settings for a short period of time. This cache will be referenced in lieu of repeated fetches. The cache will be valid across multiple app sessions.