iOS Integration - Getting started
Prerequisites
- Xcode 15.0+
- Make sure that your project meets these requirements:
- Swift 5.7
- Minimum deployment: iOS 14.0
- Have credentials for jFrog
- Have credentials for our portal
How to include
Cocoapods
Phoenix Sdk is distributed with Cocoapods using our Podspec repo. Be sure to have CocoaPods installed, or follow this guide to install it.
Then it is necessary to configure our Spec Repo.
-
Add credentials in the netrc file
Copy this then close and saveNote
If you get an error of this type: "Permission bits, should be 0600, but are 644"
Run this command:
chmod 0600 ~/.netrc
-
Create a Podfile if you don't already have one. From the root of your project directory, run the following command
-
To your Podfile, be sure that the platform is at least 13.2 then add the CocoaPods specs source and our Nextome source. Then add the PhoenixSdk pod
-
Install the pods, then open your .xcworkspace file to see the project in Xcode
-
Open your
xcworkspace
file
Setup
In order to work properly the SDK requires to setup some permissions and capabilities:
Add Background capabilities
If your app needs to compute the position even if it is in background, it is required to add the background capability.
- Select your project in Xcode’s Project navigator.
- Select the app’s target in the Targets list.
- Click the Signing & Capabilities tab in the project editor.
-
Add the background capability
-
Add Location Updates, Background Fetch and Background Processing capabilities
Add permissions
Add these permissions in the info.plist
:
- Privacy - Bluetooth Always Usage Description
- Privacy - Location Always and When In Use Usage Description
- Privacy - Location Always Usage Description
- Privacy - Location When In Use Usage Description
- Permitted background task scheduler identifiers -> com.nextome.sdk.proximity.bgranging
Retrive SDK Credentials
Log-in the web dashboard and retrieve the Client
and Secret Key
for the SDK.
Those credentials are available from your profile, in the Apps section.
SDK Initialization
First import the Proximity SDK Module
Then initialize the NextomeProximitySdk.
Initialize the Nextome Proximity SDK inside application(_:didFinishLaunchingWithOptions:)
method in your AppDelegate class like below.
Do that inside didFinishLaunchingWithOptions method of AppDelegate, allow the application to register correctly the listener of beacons and call delegates methods on wake up of the application
if it has been killed.
It requires the given Client
and Secret Key
.
...
import NextomeProximity
...
@UIApplicationMain
class AppDelegate: UIApplicationDelegate {
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
...
NextomeProximitySdk.shared.instance.initialize(clientId: CLIENT_ID, clientSecret: CLIENT_SECRET)
NextomeProximitySdk.shared.instance.getInteractionsObservables().watch(block: { interaction in
// Got interaction, do something like notifiy at the user
})
...
}
...
}
Note
By default the SDK works with settings defined in the web portal. The NextomeProximitySdk allows to override some of those as described in the next sections. But please notice that this operation is extremely dangerous and should only be made in accordance with the Nextome Team because has an huge impact on the proximity's performance.
Warning
If during build phase you encounter an error like this error: Sandbox: rsync.samba(86184) deny(1) file-write-create /Users/...../Frameworks/SSZipArchive.framework/SSZipArchive.bundle
, then go to build settings of your project, search for ENABLE_USER_SCRIPT_SANDBOXING property and set it to 'NO'
Next steps
- See Start Proximity to use Nextome SDK.
Examples
A full working example app is available on this repository.
© 2023 Nextome srl | All Rights Reserved.