Skip to content

Getting Started with ButterflyMX iOS SDK Demo App

sviatoslavbmx edited this page Mar 26, 2024 · 2 revisions

Using the Demo App

To become familiar with the ButterflyMX iOS SDK, review our demo app with basic functionality implemented.

Demo app features:

  • Authentication
  • Register/Unregister Webhooks for each unit
  • Receive and answer a audio/video call
  • Open a door within a call
  • List all the available doors
  • Open "Swipe to open" any available door (different from the open within a call)

To Set up local server

To set up ngrok service

What is ngrok?

Ngrok exposes local servers behind NATs and firewalls to the public internet over secure tunnels. We will use a ngrok URL as a webhook callback URL and forward any requet from ButterflyMX backend server to your local server in docker.

Download and setup ngrok

Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled.png

To run docker service

Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%201.png

To get started with the sample app

Compatible with Xcode >= 12

Make sure before you start working with the demo app you got ClientID and SecretID from ButterflyMX and you have a tenant account created (we can have a link to the process here https://butterflymx.readme.io/docs/getting-started-in-the-sandbox password is Butterfly123456).

Your credentials are attached to the specific environment (production/sandbox), make sure you use the demo app with the correct environment settings.

Make sure redirect URL is configured for your oAuth Application. It should be demoapp://test

  1. Download the sample app from the current (link to repo https://github.com/runslikebutter/ios-demo-app) repository

  2. Open ButterflyMX Demo.xcodeproj

  3. Select ButterflyMX Demo project and set your company bundle identifier (Example: com.companysite.demo.butterflymx.app) and Team profile that has appropriate access to the developer portal

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%202.png

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%203.png

  4. Update ClientID and SecretID in the Info.plist file. Update only the setting for the specific environment (sandbox or production):

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%204.png

  5. Go to UnitTableViewCell.swift, find toggleRegisterWebhook function, change the ngrokId in the screenshot below to the one shown on your own ngrok terminal.

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%205.png

  6. Run the project on the simulator (select the desired simulator device) or real device. If the compilation process is successful you will see the app running on the simulator or a device.

    (* The video call can only be received on a real device not on a simulator)

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%206.png

  7. The demo app requests access to the mic and camera in order to function properly. This is needed for the audio/video calls.

  8. Select the desired environment (one that you configured with the ClientID and SecretID )

  9. Press Sign in button to log in with your tenant account.

  10. Enter your tenant login and password and confirm. The application will redirect you to the page of BASIC FEATURES

![Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%207.png](Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%207.png)
  1. Tap Open Door, the application will show a page with all units. You can register/unregister Webhook for each unit by toggling the Webhook switch button for the unit. You won't get a call from a panel in a unit unless you register a Webhook for the unit.

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%208.png

  2. Open a door directly from the app. Tap"Available", you will see a panelist screen. Tap "Press to Open" button by a panel, the door controlled by the panel will be opened.

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%209.png

  3. Open a door by starting a call from your panel

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%2010.png

  4. Then you will receive a call on your iPhone

    Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%2011.png

  5. Accept the call, you will see a screen like below. You can see your visitor, talk with the visitor, and open the door for the visitor.

Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%2012.png

Using%20the%20Demo%20App%20ffaf40002acf4c48a996e74c088ebd62/Untitled%2013.png