Skip to main content

Requirements

Permissions (Optional)

Permissions to be added in info.plist file of your application
If any permission is not given then that particular feature will not be accessible in your app.

Installation

Using Swift Package Manager (SPM)

To add Genuin SDK to your iOS project via Swift Package Manager: 1. In Xcode, go to: File > Swift Packages > Add Package Dependency 2. When prompted, enter the Genuin SDK repository URL:
3. Choose the version:
Note: Make sure all Genuin SDK modules are added with the same version (2.1.1) for compatibility. Module Dependency Structure The Genuin SDK is composed of multiple interdependent modules. These follow a linear dependency chain as outlined below:
Integration Rules
  1. core - Can be used independently. It is the foundation for all other modules.
  2. ui - Requires core. Must be added together.
  3. camera - Requires both core and ui.
  4. ai - Requires camera, ui, and core.
Ensure modules are added in the correct order and with the same version to avoid conflicts during build and runtime.

Using Cocoapods

If your project doesn’t have the CocoaPods setup then start with pod init which will create the Podfile, else do following changes in the pod file to install GenuinSDK.
a. For Core SDK:
b. For UI SDK:
c. For Camera SDK:
d. For AI SDK:
Example Import the GenuinSDK module in your SceneDelegate/AppDelegate.
Cocoapods (with all sdk initialize)
To load your lottie animation accross the Genuin SDK, you can add it here configuration.setCustomLoader("YOUR_LOADER", bundle: .main)

Instructions for SceneDelegate:

  1. Ensure you are using the UISceneDelegate in your app.
  2. In your SceneDelegate.swift file, implement the scene(_:willConnectTo:options:) method.
  3. Use the shared configuration and set up any custom loaders or additional parameters.
  4. Call GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration) with your API key and the configured options.
  5. Ensure that GenuinSDK.shared.scene(scene, willConnectTo: session, options: connectionOptions) is called to notify the SDK of the scene connection.

Instructions for AppDelegate:

  1. In your AppDelegate.swift, implement the application(_:didFinishLaunchingWithOptions:) method.
  2. Set up the shared configuration and initialize the SDK with your API key.
  3. Call GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration) with your API key and the configured options.
  4. Return true to indicate successful launch configuration.

Instructions for SwiftUI:

In your SwiftUI’s App file initialize the GenuinSDK as follows:
Note: Our SDK is well optimized for iOS version 15.0 and above, but if you are using iOS version 13 or 14 then put this if #available(iOS 15.0, *) condition while importing the GenuinSDK.

Monetization

To enable Monetization use following code snippet to get advertisingIdentifier by AppTrackingTranspancy. You need to add NSUserTrackingUsageDescription in Info.plist as described here.
Also if you enable monetization then you need to update App Privacy in AppStoreConnect
Need to declare in App Store Connect that your app is using Advertising DataSteps:
  • Log in to your App Store Connect.
  • Select the app you are working on.
  • Go to App Privacy > Data Collection.
  • Find the Usage Data section and select the Advertising Data.
  • Click on Save/Publish.
  • Now Setup Advertising Data by selecting (Third-Party Advertising, Analytics, Product Personalization, App Functionality, Other Purposes)
  • Click on Next and give the answers as asked.
  • Click on save.

Embed with Swift

Note: Make sure you have followed the installation steps in order to implement the Carousel Embed.
Note: In order to migrate from GenuinSDK 1.0 to 2.0, you need to replace import GenuinSDK to import GenuinCore in your codebase.
Refer to Carousel View in Mobile
We have introduced new attribute GenuinEmbedAttributes that holds all the required data attributes needed to create and initialize an embed. You can initialize it with the following parameters:
Parameters
  • embedId: String – The identifier for the embed.
  • uniqueId: String? (optional) – A unique identifier, if needed.
  • viewController: UIViewController – The parent view controller for presenting the embed.
  • ssoToken: String? (optional) – Single Sign-On token for authentication.
  • params: [String: Any]? (optional) – Additional parameters for customization.
  • contextualParams: [String: Any]? (optional) – Context-specific parameters for the embed.
  • embedConfiguration: EmbedConfiguration (optional) – Configuration object for customizing embed behavior. Defaults to a new EmbedConfiguration instance.
Creating and Loading an Embed You can create and load a GenuinEmbedView in following ways:

Approach 01

Note: To fetch the Embed you need to add YOUR_EMBED_ID, YOUR_CONTAINER_VIEW in which you want the embed, and YOUR_VIEW_CONTROLLER containing your container view, while calling the below function. For auto login in the SDK, you shall pass “YOUR_SSO_TOKEN” in order to implement Embed with SSO in your app.

Approach 02

Initialize with Attributes During Creation Create the GenuinEmbedAttributes first, then pass it directly while initializing the embed view:

Approach 03

Initialize First, Then Set Attributes Create the embed view first and assign the attributes afterward:

Approach 04

Adding the Embed View in a Storyboard Steps:
  1. When using Interface Builder, first create a wrapper view with your preferred height and constraints. This wrapper will serve as the container for the GenuinEmbedView.
  2. Drag a UIView for embed and add it inside your wrapper view.
  3. Set the embed view’s class to GenuinEmbedView in the Identity Inspector.
  4. If a module for the specified class does not appear , then set the module as GenuinCore in the module field below the class.
  5. Connect it to an @IBOutlet in your view controller (e.g., embedView).
  6. Example: Initialize and Load with an Outlet
  1. Call loadEmbed() to initialize and load the embed.
Check the additional information here.

Full Screen Embed

Note: To fetch the Embed you need to add YOUR_EMBED_ID, YOUR_CONTAINER_VIEW in which you want the embed, and YOUR_VIEW_CONTROLLER containing your container view, while calling the above function. For auto login in the SDK, you shall pass “YOUR_SSO_TOKEN” in order to implement Embed with SSO in your app.

Standard Wall Embed

Note: To fetch the Embed you need to add YOUR_EMBED_ID while calling the above function.

Embed with SwiftUI

Refer to Carousel View in Mobile
Genuin Carousel Embed View Wrapper
Example Usage

Standard Wall Embed

Standard Wall View Wrapper
Example Usage
Note: To fetch the Embed you need to add YOUR_EMBED_ID while calling the above function.

Additional Information

To configure the EmbedConfiguration based on your need you can change the below values.
  1. isShowProfileEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true and also if user is logged in than Profile picture will be visible in full screen view (right side top corner). On clicking the profile picture user will see the account settings and logout options.
  2. isDirectDeepLinkEnabled = This is an optional boolean parameter. Default value is false. If this parameter is true then all the interaction/clicks in the full screen view will redirect to the specific video in white labelled app associated with video and also value of this parameter “interactionDeepLink” will be ignored. If not passed then the regular flow will work.
  3. interactionDeepLink = This is an optional parameter. You can pass a deeplink URL in this parameter. If a deeplink URL is given then all the interaction/clicks in the full screen view will redirect to the deeplink URL given. If not passed then the regular flow will work. It should be a correct URL else user will not be redirected.
  4. genuinCarouselConfiguration = This is an optional parameter. You can pass GenuinCarouselConfiguration object in this parameter. If GenuinCarouselConfiguration is provided then the carousel design will change accordingly. The default values are listed below, which you can pass in GenuinCarouselConfiguration object.
    • interTileSpacing - spacing between the carousel’s collection view items. It’s default value is 8.0
    • viewInset - edge insets for carousel’s collection view. It’s default value is UIEdgeInsets(top: 8.0, left: 16.0, bottom: 0.0, right: 16.0)
    • tileCornerRadius - cornerRadius for the carousel’s collection view items. It’s default value is 8.0
Below are the optional parameters for the params key:
  1. name - This is an optional string parameter. Pass this parameter for ‘signup/login’.
  2. mobile - This is an optional string parameter. Pass this parameter for signup/login.
  3. email - This is an optional string parameter. Pass this parameter for signup/login.
  4. nickname - This is an optional string parameter. If nickname is available in genuin ecosystem it will be used, else genuin will generate of its own.
  5. profile_image: This is an optional string parameter. Pass the profile_image parameter if you want to show the profile image in the SDK.
Below are the optional parameters for the contextualParams key:
  1. page_context - This is an optional string parameter. Pass this parameter for ‘context’, so that feed could load based on that context.
  2. lat - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the latitude and context.
  3. long - This is an optional float parameter. Pass this parameter in geo so that the feed could load based on the longitude and context.
Note: lat and long both parameters shall be passed in order to implement the contextual feed based on the location.
Example
Note: You can pass above parameters in GenuinEmbedAttributes as well

Placement with Swift

Note: Make sure you have followed the installation steps in order to implement the Carousel Embed.
Note: In order to migrate from GenuinSDK 1.0 to 2.0, you need to replace import GenuinSDK to import GenuinCore in your codebase.
GenuinPlacementAttributes We have introduced new attribute GenuinPlacementAttributes which is used to hold all the necessary data for creating and initializing a placement view. You can initialize it with the following parameters:
Parameters
  • placementId: String – Identifier for the placement.
  • styleId: String – Identifier for the placement style.
  • uniqueId: String? (optional) – Unique identifier for this placement instance.
  • viewController: UIViewController – Parent view controller that will present the placement.
  • ssoToken: String? (optional) – Single Sign-On token for authentication.
  • params: [String: Any]? (optional) – Additional parameters to customize the placement.
  • contextualParams: [String: Any]? (optional) – Context-specific parameters for the placement.
  • placementConfiguration: PlacementConfiguration (optional) – Custom configuration object. Defaults to a new instance of PlacementConfiguration.
Creating and Loading an Placement You can create and load a GenuinPlacementView in following ways:

Approach 01

Initialize placement

Approach 02

Initialize with Attributes During Creation Create the GenuinPlacementAttributes first, then pass it directly while initializing the placement view:

Approach 03

Initialize First, Then Set Attributes Create the placement view first and assign the attributes afterward:

Approach 04

Adding the Placement View in a Storyboard Steps:
  1. When using Interface Builder, first create a wrapper view with your preferred height and constraints. This wrapper will serve as the container for the GenuinPlacementView.
  2. Drag a UIView for placement and add it inside your wrapper view.
  3. Set the placement view’s class to GenuinPlacementView in the Identity Inspector.
  4. If a module for the specified class does not appear , then set the module as GenuinCore in the module field below the class.
  5. Connect it to an @IBOutlet in your view controller (e.g., placementView).
  6. Example: Initialize and Load with an Outlet
  1. Call loadPlacement() to initialize and load the placement.

Loading Embed and Placement Views in the Background

You can fetch data for an embed or placement view in the background as per your requirement and add it to your view hierarchy once the data is ready.

Example: Loading an Embed in the Background

Example: Loading a Placement in the Background

Handle Login : via AutoLogin Approach

To Auto Login in the SDK, You need to call below method, whenever user is log in to your application.
Note: You don’t need to call the below method if you have implemented the Embed With SSO already.
Handle AutoLogin in Embed

Custom Login

If you want to handle login process as per your requirement then follow the below steps: Step 1: Assign Delegate while initializing Genuin SDK
Step 2: Extend GenuinDelegate & Present your own controller on provided base controller
Step 3: Must call below login service from Genuin, to keep user logged in, in Genuin SDK.

Handle Logout : via AutoLogin Approach

Whenever user logs out from your application call the below method.
Note: Make sure you have followed the installation steps in order to handle the deep links.
Prerequisite:
  1. Make sure you have white labelled your community by following these steps
  2. Enable Associated Domains in Certificates, Identifiers & Profiles using your Apple Developer account at https://developer.apple.com/account/resources/identifiers/list
  3. Create apple-app-site-association (without extension) file with following settings:
Once the file is created, host it on the white labeled domain at https://YOUR_WHITE-LABELLED_DOMAIN/.well-known/apple-app-site-association
  1. Add Associated Domains in capabilities if not already,
Add applinks in domains, for Example: applinks: YOUR_WHITE-LABELLED_DOMAIN applinks: www.YOUR_WHITE-LABELLED_DOMAIN To handle deep links in your app use the following methods.
Note: GenuinSDK.shared.willHandleDeepLink(url: dlURL) function will check whether GenuinSDK will handle the given deeplink or not. You can use it according to your deeplink redirection flow.

Instructions for SceneDelegate:

Handle deep links using the root view controller by calling GenuinSDK.shared.handleDeeplink(viewController: rootVC).

Instructions for AppDelegate:

Use GenuinSDK.shared.handleDeeplink(viewController: rootVC) to manage the deep link using the app’s root view controller.
Note:
  1. To handle the Deeplink from another controller call the GenuinSDK.shared.handleDeeplink(viewController: vc) function from specific controller
  2. If you are following the SceneDelegate method then calling this GenuinSDK.shared.handleDeeplink(viewController: self) function is mandatory

Optional LinkOutInterceptor

If you want to intercept Linkout clicks, you can implement GenuinLinkOutInterceptorDelegate as below: Step 1: Assign Delegate GenuinLinkOutInterceptorDelegate:
Note:ARRAY_OF_ASSOCIATED_DOMAINS_HANDLED_BY_YOUR_APP accepts associcated domains supported by your apps. You can pass comma seperated domains like e.g. [“apple.com”, “https://apple.com”, “www.apple.com”, “applinks:apple.com”]YOUR_ANY_CLASS can be class which you want to handle the delegate method in.
Step 2: Handle callback method

Handling Push Notifications

Using Firebase

  1. Create an app in your firebase console by following these steps
  2. Download the GoogleService-Info.plist file and add it in xcode project
  3. Add pod in pod file
  1. To enable the push notifications functionality then enable the Push Notifications in your target. To do so, Select the target > Signing & Capabilities > Add Capability of Push Notification
  2. Import
AppDelegate
Note: Pass true value in isFCMIntegrated parameter, as we are using the Firebase.
  1. Initialize
SceneDelegate
  1. Place this code to take the user permission for Push Notification
  1. Extend MessagingDelegate and Add follwing method:
  1. To Handle the Push Notification Redirection whenever the user taps, follow the below code
Note: GenuinSDK.shared.willHandleNotification(userInfo: userInfo) function will check whether GenuinSDK will handle the given notification or not. You can use it according to your notification redirection flow.
  1. To configure notification UI
  1. If you want to handle the notification when app is opened then follow the below code
Note: To handle the notification from another controller call the GenuinSDK.shared.handleNotifications(viewController: YOUR_VIEW_CONTROLLER) function

Using APNS

  1. To enable the push notifications functionality then enable the Push Notifications in your target. To do so, Select the target > Signing & Capabilities > Add Capability of Push Notification
  2. Import
AppDelegate
Note: Pass false value in isFCMIntegrated parameter, as we are not using the Firebase.
SceneDelegate Initialize
  1. Place this code to take the user permission for Push Notification
  1. To Handle the Push Notification Redirection whenever the user taps, follow the below code
Note: GenuinSDK.shared.willHandleNotification(userInfo: userInfo) function will check whether GenuinSDK will handle the given notification or not. You can use it according to your notification redirection flow.
  1. To configure notification UI
  1. If you want to handle the notification when app is opened then follow the below code
Note: To handle the notification from another controller call the GenuinSDK.shared.handleNotifications(viewController: YOUR_VIEW_CONTROLLER) function.

What’s next?

Android SDK

Integrate Android SDK in Your ecosystem.

Web SDK

Integrate Web SDK in your ecosystem.

React Native SDK

Integrate React Native SDK in your ecosystem.

Support

If you need any assistance or have any questions, feel free to email us at support@begenuin.com.