This example project was created by Tedee team to show you how to use Tedee Mobile SDK for iOS.
This project was created using Swift language and run it on iOS device.
Using this example you will be able to connect and communicate with only one lock at the time.
- Tedee Lock - you can order it in our online store
- iPhone (real device) with iOS 17.2+ and installed Tedee app
- Mac with
Sonoma
or newer macOS installed - USB - Lightning cable (to connect iPhone to Mac)
- Xcode 15.2+ from App Store
- Tedee account created in Tedee app
- Lock is paired with (added to) Tedee account.
- Lock
Serial number
andDevice ID
from Tedee app- go to:
Lock details > Settings (gear icon) > Information
- go to:
Warning
This project cannot be run on Xcode simulator, you will have to run it on physical device (iPhone).
-
clone this repository
-
open
tedee example.xcodeproj
file in Xcode -
in file navigator select
tedee example
and choose targettedee example
fromTARGETS
-
change
Team
toPersonal Team
-
change
Bundle Identifier
to something else, for example:[YOUR COMPANY DOMAIN].tedee-example
-
On iPhone go to
Setting > Privacy & Security
, scroll to the bottom toSecurity
section, tap onDeveloper Mode
and enable it -
Connect iPhone to your Mac with
USB - Lightning
cable -
Click in the top bar on
Any iOS Device
or similar text right totedee example
target -
Cancel
Create a new simulator
window -
On the left sidemenu select
Devices
and click on the+
icon at the bottom -
Tap
Trust
on iPhone to trust your Mac connection and confirm with your iPhone passcode
-
You can select
Connect via Network
for connecting Xcode to iPhone via WiFi but we do not recommend this if you do not have experience with Xcode
Now you are ready to build the project and upload it to your iPhone.
Cmd + R
will build project and run it on connected iPhone.- Unlock your iPhone during build to give Xcode right to upload and start app on it.
On first launch app will ask you for permission to use Bluetooth.
App will also generate public key that is required to lock certificate (see next steps). Look for Public key to register in api:
in Xcode console. If it didn't opened tap on the in bottom bar to open Xcode console. You will see there also steps that are taken by the app to unlock the lock (connect, start encrypted session, send unlock command, receive response).
-
log in to Tedee Portal with credentials from created Tedee account
-
click on Personal Access Keys and generate new access key with permissions:
- Device certificates - Operate
- Mobile devices - Read
- Mobile devices - Write
-
Go to Tedee API and authorize yourself with created Personal Access Key
- proper format is
PersonalKey [YOUR PERSONAL ACCESS KEY]
- confirm with
Authorize
- go to
Mobile
section and usePOST /api/[api version]/my/mobile
route and click on try it out - enter
name
(lock name from Tedee iOS app),operatingSystem
set to3
andpublicKey
the one that was generated bytedee example
app on first launch - response will return
id
that is required in next step (asMobileID
) - go to
DeviceCertificate
section and use/api/[api version]/my/devicecertificate/getformobile
- click on
Try it out
- fill
MobileID
gathered from previous request response andDevice ID
from Tedee app - store somewhere response result, you will need it in next step
Warning
Generated certificate has expiration date, which is attached to the response with certificate. After certificate expiration you will not be able to operate the lock and you need to get new one.
- open
Configuration.swift
in project navigator - replace empty value of
SerialNumber
with your Tedee lock serial number - replace empty value of
CertificateString
withcertificate
value from last API request results - replace empty value of
Expiration
withexpirationDate
value from last API request results - replace empty value of
DevicePublicKey
withdevicePublicKey
value from last API request results - replace empty value of
MobilePublicKey
withmobilePublicKey
value from last API request results
- compile and run app again with
Cmd + R
- if everything is configured properly you should be able to connect to the lock, send commands to it and see bluetooth notification send by the lock (e.g. when you manually close or open lock)
Important
if you have issue with connecting to the lock and sdk returns secureSessionFailed
error, open Tedee app and make sure that Tedee app is able to connect to the the same lock and you are able to lock/unlock your lock. After that, this example app should be able to successfully connect to the lock.