Unity (iOS)
This guide is for anyone who wishes to integrate the Enefits Unity SDK for iOS into the Unity project. We highly recommend reviewing the General Usage guide to familiarise yourself with general SDK workflow concepts before continuing. You will need to generate an API key with your Enefits account before continuing with integration.
To obtain an API key, simply register at https://x.enefits.co/, and go to Developer in the account menu in the top right section. From there, generate an API key and save this for SDK initialization.

We only show this once, so if you lose this API Key, you’ll have to re-generate it from the Developer section.
To run a live demo, download EnefitsSDKDemoApp. Open it with Unity and provide your own API key where requested. Also, note that EnefitsSDKDemoApp requires an iOS device to work. It will not work in the Unity Editor Or the iOS Simulator.
Make sure you have ios Build options support available in Unity.

Also, make sure you have XCode OR XCode Command Line Tools installed. Go to Unity -> File -> Build Settings.
Make sure 'iOS' option is selected. Select option 'Build', it will ask for a location where unity will generate iOS Project.
Select a location, then it will generate iOS Project at a specified location.
Open generated XCode Project File with XCode.

Make sure you have enabled XCode Project with a valid developer profile & signing certificates and valid Application Bundle Id.

Change Bundle Identifier, version and build number as per your requirement.
You can either run EnefitsSDKDemoApp on the device or create a generic device build.

Select a valid provision profile and a valid signing certificate.

The EnefitsSDK Unity iOS package can be downloaded from this link.
Select Project layout. Go to the Assets folder. Right-click and select Import Package -> Custom Package.

Select a downloaded Enefits package and choose 'Open'. Make sure all components are selected from the package and then click on 'Import'.

Please make sure to call any SDK method inside 'UNITY_IOS && !UNITY_EDITOR' block, as it is only available for iOS:
<App_Name> - string type - describes your unity ios application name
<API_key> - string type - API key provided to you during the registration at https://x.enefits.co/.
completionHandler can be defined as:
status => true/false SDK init success/failed
message => error / message from the Enefits SDK
Display a button or call-to-action (for example: 'Connect Wallet') which when tapped will prompt the user to connect a wallet.
After the user selects a wallet and initiates a session, the returned address will be available to the Enefits SDK to check NFTs and any offers the user is eligible for.
This function will open a view with a list of supported providers
Enefits SDK fires the callback after successfully connecting with a blockchain account.
where completionHandler can be defined as:
status = true => Connecting with wallet
status = false => Already connected or not initialized
message => string message from the Enefits SDK
To get callback after wallet connect:
walletcompletionHandler can be defined as:
status = true => Conected with wallet successfully.
status = false => failed to connect wallet.
This method returns all Offers that the user is eligible for based on the address they provided when they connected their wallet.
completionHandler can be defined as:
status = true => able to fetch offers successfully.
status = false => failed to get offers.
message => if status = true then message describes offers list (JSON string), if status = false, then message describes error info.
Use the functions provided below to create tighter integration with the Enefits SDK and manage user connectivity states.
where getConnectAccountcompletionHandler can be defined as:
account => Connected account information.
blockChainInfo => Wallet information (JSON string)
where getChainDatacompletionHandler can be defined as:
data => blockchain info for the connected account (JSON string).
where completionHandler can be defined as:
status = true/fase => able to disconnect from wallet successfully / failed to disconnect from wallet.
message => if status = false then message explains reason for failure while disconnecting.