ALSDK iOS Framework
This guide explains how to integrate the ALSDK framework into your iOS app. You can choose either manual integration or the Swift Package Manager (SPM) method. For dynamic development and easier updates, we recommend using SPM.
Prerequisites
iOS Deployment Target: iOS 12 or later
Xcode: Version 11 or higher
ALSDK.xcframework: The prebuilt framework file
Integration Options
Manual Integration
Download the Framework:
Obtain the
ALSDK.xcframework
folder.
Add to Your Xcode Project:
Open your project in Xcode.
Drag and drop the
ALSDK.xcframework
folder into your Project Navigator.Tip: Check “Copy items if needed” to include a local copy.
Link the Framework:
Select your app target.
Go to the General tab.
Under Frameworks, Libraries, and Embedded Content, click the + button, select
ALSDK.xcframework
, and add it.Set the embed option to Embed & Sign if required.
Swift Package Manager Integration
In Xcode, open your project and choose File > Swift Packages > Add Package Dependency…
Enter the package repository URL.
Select the desired version (e.g., “Up to Next Major” starting at 1.0.0).
Xcode will download and integrate the package automatically.
Setup
For the SDK to be active, there are 2 key elements to add to your code.
Framework initialization
In your AppDelegate, import the framework at the top of the file:
And in the
didFinishLaunchingWithOptions
method, add the following line of code:
This is all it takes to have the SDK monitor your app! Now you need to declare the apps you want to detect.
Crypto App Detection
On iOS, mobile apps can detect the presence of other apps as long as they declare the list of apps prior to packaging the code.
To enable your app to detect the presence of other apps via canOpenURL, you need to declare the URL schemes in your app’s Info.plist using the LSApplicationQueriesSchemes key. Here’s how to do it:
Open Info.plist: In your Xcode project, select your app target and open its Info.plist file.
Add LSApplicationQueriesSchemes:
Right-click in the Info.plist editor and choose Add Row.
Set the key to LSApplicationQueriesSchemes and its type to Array.
List the Schemes:
Under the newly added array, add a new item for each URL scheme you want to query.
Save Changes: Save the file, and your app will now be allowed to call
canOpenURL
on the schemes you've listed.
Keep the list of apps to detect lean - 5 is a good number to get started. Make sure to mention to Apple during the review process that there schemes are added because you want to provide a seamless experience for your users when they will connect their crypto wallets to your app.
User ID tracking
The SDK allows you to pass it a user ID in order to reconcile visitor context, including wallet presence, and user profile.
To pass a user ID, use the following function on the SDK:
Event tracking
You can post custom events via the SDK, in order for instance to have accurate conversion reporting based on them.
To trigger the tracking of an event, call the ALSDK.postCustomEvent
function, for instance as follows:
Last updated