iOS SDK 2.0 - How to Integrate and Power Your Brand Community in iOS Apps
Overview
Use the Genuin iOS SDK 2.0 when you want to bring your Community Media Network directly into your iOS application - enabling feeds, communities, video creation, AI-powered workflows, and monetization in a fully native experience.
This matters because:
- You own the user experience inside your app (no redirects)
- You unlock zero-party data + engagement loops
- You enable content creation, discovery, and monetization in one ecosystem
The SDK is modular, allowing you to integrate only what you need, from core embeds to advanced AI and camera capabilities.
SDK Architecture
The Genuin iOS SDK is composed of modular components:
| SDK | Description |
|---|---|
| GenuinCore | Includes the core functionality of the Genuin Ecosystem: Embeds and User authentication. |
| GenuinUI | Additional UI flows like comments, search, deep-links, notifications, group/community detail etc. |
| GenuinCamera | Camera flows for video content creation. |
| GenuinAI | Additional flows for AI assisted community/group creation. |
Requirements
| Platform | Minimum Deployment Target | Language | Supported Orientations | Supported Destinations |
|---|---|---|---|---|
| iOS | 13.0 | Swift | Portrait | iPhone |
Permissions (Optional)
Permissions to be added in info.plist file of your application:
| Permission | Usage | Used Where | In SDK |
|---|---|---|---|
| Camera (NSCameraUsageDescription) | Genuin needs permissions to open your camera and microphone. This allows Genuin to record videos that can be shared with other people. | Post, Video Comment | GenuinCamera |
| Microphone (NSMicrophoneUsageDescription) | Genuin needs permissions to open your camera and microphone. This allows Genuin to record videos that can be shared with other people. | Post, Voice Comment | GenuinCamera |
| Photos (NSPhotoLibraryUsageDescription) | Genuin needs permissions to access your photo library. This allows Genuin to download videos to your phone and save it to your library. | Post, Profile, Banner | GenuinCore |
| Speech Recognition (NSSpeechRecognitionUsageDescription) | The transcript of your recording will be displayed to you in the end for you to overlay it on the audio message. | To generate transcript from recorded audio | GenuinCamera |
| Contacts (NSContactsUsageDescription) | Genuin requires to sync with your contacts and provide a better experience when you wish to share your posts with them. | Add Members in Communities and Groups | GenuinUI |
| Location (NSLocationWhenInUseUsageDescription) | Your precise location will help us suggest your community details more accurately. | AI Powered Communities based on the User Location | GenuinCore |
| Tracking (NSUserTrackingUsageDescription) | Your data will be used to analyse ads we run! | Monetization | GenuinCore |
Note: If any permission is not granted, the corresponding feature will not be available.
Installation
Using Swift Package Manager (SPM)
- In Xcode, go to: File > Swift Packages > Add Package Dependency
- Enter repository URL: https://bitbucket.org/genuindev/genuin_sdk_ios
- Choose version: Version: 2.1.1
Important: All SDK modules must use the same version.
Module Dependency Structure
ai ← camera ← ui ← core
iOS SDK 2.0 Module Integration Guide
When integrating the iOS SDK 2.0 modules, adhere to the following dependency rules:
| Module | Requirements | Notes |
|---|---|---|
| core | None | The foundational module; can be used independently. |
| ui | Requires core | Must be added alongside the core module. |
| camera | Requires core and ui | Dependent on both the core and UI foundations. |
| ai | Requires core, ui, and camera | Dependent on the full set of foundational and camera modules. |
Crucial Integration Note:
Ensure all modules are integrated using the correct version and added in the specified order to prevent build and runtime conflicts.
Using CocoaPods for Setup
To install the GenuinSDK, follow the steps below:
- If CocoaPods is not set up in your project, run pod init to create the Podfile.
- Otherwise, modify your existing Podfile to include the necessary GenuinSDK dependencies.
platform :ios, '13.0'
target 'YourProject' do
use_frameworks!
# Pods for YourProject
genuin_sdk_version = '2.1.1'
pod "GenuinCore", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_version
pod "GenuinUI", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_version
pod "GenuinCamera", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_version
pod "GenuinAI", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_version
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'Giphy'
`xcrun -sdk iphoneos bitcode_strip -r Pods/Giphy/GiphySDK/GiphyUISDK.xcframework/ios-arm64_armv7/GiphyUISDK.framework/GiphyUISDK -o Pods/Giphy/GiphySDK/GiphyUISDK.xcframework/ios-arm64_armv7/GiphyUISDK.framework/GiphyUISDK`
end
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
endpod "GenuinCore", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_versionpod "GenuinUI", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_versionpod "GenuinCamera", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_versionpod "GenuinAI", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => genuin_sdk_versionNext Step:
After integrating the necessary modules, you must import the main GenuinSDK module in your SceneDelegate or AppDelegate file (Example).
SDK Initialization
SceneDelegate Setup
import GenuinCore
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Optional configuration and attaching the UIWindow to UIWindowScene
guard let _ = (scene as? UIWindowScene) else { return }
// Initialize the SDK configuration
let configuration = GenuinConfiguration.shared
// For Production environment (Default)
configuration.setCustomLoader("YOUR_LOADER", bundle: .main)
// For QA Environment
configuration.environment = .qa
// Initialize the SDK with your API key and configuration
GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
// Notify the SDK that the scene will connect
GenuinSDK.shared.scene(scene, willConnectTo: session, options: connectionOptions)
}import GenuinCore
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize the SDK configuration
let configuration = GenuinConfiguration.shared
// For Production Environment (Default)
configuration.setCustomLoader("YOUR_LOADER", bundle: .main)
// For QA Environment
configuration.environment = .qa
// Initialize the SDK with your API key and configuration
GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
return true
}GenuinUI.shared.initialize() //Initialize method is required if GenuinUI sdk is integrated
GenuinCamera.shared.initialize() //Initialize method is required if GenuinCamera sdk is integrated
GenuinAI.shared.initialize() //Initialize method is required if GenuinAI sdk is integrated
GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)Custom Loader Configuration:
To use a custom Lottie animation as a loader across the Genuin SDK, configure it as follows:
configuration.setCustomLoader("YOUR_LOADER", bundle: .main)
Integration Instructions for SceneDelegate:
If your app uses UISceneDelegate, follow these steps in your SceneDelegate.swift:
- Verify that your application implements UISceneDelegate.
- Implement the scene(_:willConnectTo:options:) method.
- Set up the shared SDK configuration, including any custom loaders or parameters.
- Initialize the SDK by calling: GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
- Ensure the SDK is notified of the scene connection by calling: GenuinSDK.shared.scene(scene, willConnectTo: session, options: connectionOptions)
Integration Instructions for AppDelegate:
For AppDelegate-based initialization, use the following steps in your AppDelegate.swift:
- Implement the application(_:didFinishLaunchingWithOptions:) method.
- Configure the shared options and proceed to initialize the SDK with your API key.
- Initialize the SDK by calling: GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
- Return true from the method to confirm a successful launch configuration.
import GenuinCore
import GenuinUI
import GenuinCamera
import GenuinAI
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Optional configuration and attaching the UIWindow to UIWindowScene
guard let _ = (scene as? UIWindowScene) else { return }
// Initialize the SDK configuration
let configuration = GenuinConfiguration.shared
// For Production environment (Default)
configuration.setCustomLoader("YOUR_LOADER", bundle: .main)
// For QA Environment
configuration.environment = .qa
GenuinUI.shared.initialize() //Initialize method is required if GenuinUI sdk is integrated
GenuinCamera.shared.initialize() //Initialize method is required if GenuinCamera sdk is integrated
GenuinAI.shared.initialize() //Initialize method is required if GenuinAI sdk is integrated
// Initialize the SDK with your API key and configuration
GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
}import GenuinCore
import GenuinUI
import GenuinCamera
import GenuinAI
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize the SDK configuration
let configuration = GenuinConfiguration.shared
// For Production Environment (Default)
configuration.setCustomLoader("YOUR_LOADER", bundle: .main)
// For QA Environment
configuration.environment = .qa
GenuinUI.shared.initialize() //Initialize method is required if GenuinUI sdk is integrated
GenuinCamera.shared.initialize() //Initialize method is required if GenuinCamera sdk is integrated
GenuinAI.shared.initialize() //Initialize method is required if GenuinAI sdk is integrated
// Initialize the SDK with your API key and configuration
GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
return true
}import SwiftUI
import GenuinCore
import GenuinUI
import GenuinAI
import GenuinCamera
@main
struct GenuinSwiftUIApp: App {
init() {
let configuration = GenuinConfiguration()
// For QA Environment
configuration.environment = .qa
configuration.setCustomLoader("YOUR_LOADER", bundle: Bundle.main)
GenuinUI.shared.initialize()
GenuinCamera.shared.initialize()
GenuinAI.shared.initialize()
GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}SDK Compatibility and Initialization
The GenuinSDK is optimized for iOS 15.0 and later. If you are targeting iOS 13 or 14, you must wrap the SDK import statement with the if #available(iOS 15.0, *) condition.
Enabling Monetization
To utilize monetization features, you need to obtain the advertisingIdentifier via AppTrackingTransparency. You must also include the NSUserTrackingUsageDescription key in your Info.plist file. Refer to the permissions documentation here for details.
import AppTrackingTransparency
import AdSupport //Import only if you want to use advertisingIdentifier
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
DispatchQueue.main.async {
ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .notDetermined:
break
case .restricted:
break
case .denied:
break
case .authorized:
// If you want to check the current advertisingIdentifier
print("advertisingIdentifier: ", ASIdentifierManager.shared().advertisingIdentifier.uuidString)
break
@unknown default:
break
}
}
}
}
}import AppTrackingTransparency
import AdSupport //Import only if you want to use advertisingIdentifier
class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationDidBecomeActive(_ application: UIApplication) {
DispatchQueue.main.async {
ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .notDetermined:
break
case .restricted:
break
case .denied:
break
case .authorized:
// If you want to check the current advertisingIdentifier
print("advertisingIdentifier: ", ASIdentifierManager.shared().advertisingIdentifier.uuidString)
break
@unknown default:
break
}
}
}
}
}If monetization is enabled in your app, you must update the App Privacy settings in App Store Connect to declare the use of Advertising Data.
Steps to Declare Advertising Data in App Store Connect:
- Log in to your App Store Connect account.
- Select the relevant app.
- Navigate to App Privacy > Data Collection.
- In the Usage Data section, select Advertising Data.
- Click Save/Publish.
- Set up the Advertising Data by selecting the following purposes:
- Third-Party Advertising
- Analytics
- Product Personalization
- App Functionality
- Other Purposes
- Click Next and provide the requested answers.
- Click Save.
Embed with Swift
Note: Ensure you have completed the necessary installation steps before implementing the Carousel Embed.
Migration Note: When migrating from GenuinSDK 1.0 to 2.0, you must replace import GenuinSDK with import GenuinCore in your codebase.Carousel Embed
For a visual reference, see the Carousel View in the Mobile section.
The SDK introduces a new attribute, GenuinEmbedAttributes, which encapsulates all the required data attributes for creating and initializing an embed. You can initialize this attribute using the following parameters:
init(
embedId: String,
uniqueId: String? = nil,
viewController: UIViewController,
ssoToken: String? = nil,
params: [String: Any]? = nil,
contextualParams: [String: Any]? = nil,
embedConfiguration: EmbedConfiguration = EmbedConfiguration()
)Parameters for GenuinEmbedView
The following parameters are used when creating and loading a GenuinEmbedView:
| Parameter | Type | Description |
|---|---|---|
| embedId | String | Required. The unique identifier for the embed content. |
| viewController | UIViewController | Required. The parent view controller responsible for presenting the embed. |
| uniqueId | String? (Optional) | A unique identifier for the instance, if necessary. |
| ssoToken | String? (Optional) | A Single Sign-On token for user authentication. |
| params | [String: Any]? (Optional) | A dictionary for passing additional, general customization parameters. |
| contextualParams | [String: Any]? (Optional) | A dictionary for passing parameters specific to the current context of the embed. |
| embedConfiguration | EmbedConfiguration (Optional) | A configuration object to customize the embed's behavior. It defaults to a new EmbedConfiguration instance if not provided. |
Creating and Loading an Embed
You have the following methods (e.g., Approach 01) to create and load a GenuinEmbedView:
let embedConfiguration = EmbedConfiguration()
embedConfiguration.isShowProfileEnabled = false
embedConfiguration.isDirectDeepLinkEnabled = false
GenuinSDK.shared.initializeEmbed(embedId: "YOUR_EMBED_ID", containerView: <YOUR_CONTAINER_VIEW>, viewConroller: <YOUR_VIEW_CONTROLLER>, ssoToken: <YOUR_SSO_TOKEN>, embedConfiguration: embedConfiguration)let embedConfiguration = EmbedConfiguration()
embedConfiguration.isShowProfileEnabled = false
embedConfiguration.isDirectDeepLinkEnabled = false
GenuinSDK.shared.initializeEmbed(embedId: "YOUR_EMBED_ID", containerView: <YOUR_CONTAINER_VIEW>, viewConroller: <YOUR_VIEW_CONTROLLER>, embedConfiguration: embedConfiguration)let embedConfiguration = EmbedConfiguration()
embedConfiguration.isShowProfileEnabled = false
embedConfiguration.isDirectDeepLinkEnabled = false
GenuinSDK.shared.initializeEmbed(embedId: "EMBED_ID", uniqueId: "YOUR_UNIQUE_ID", containerView: YOUR_VIEW, viewConroller: YOUR_VIEW_CONTROLLER, ssoToken: "YOUR_SSO_TOKEN", params: ["name" :"FULL_NAME", "nickname" : "USER_NAME", "mobile" :"MOBILE_NO"], contextualParams: ["page_context": "CONTEXT_TEXT", "geo": { "lat": LATITUDE_VALUE, "long": LONGITUDE_VALUE }], embedConfiguration: embedConfiguration)To initialize the embed with attributes, follow Approach 02: Initialize with Attributes During Creation
First, create the GenuinEmbedAttributes. Then, pass this object directly when initializing the embed view.
Note: When calling the function to fetch the Embed, you must provide the following:
- YOUR_EMBED_ID
- YOUR_CONTAINER_VIEW (the view where the embed will be placed)
- YOUR_VIEW_CONTROLLER (the view controller containing your container view)
For implementing Single Sign-On (SSO) with the Embed, pass YOUR_SSO_TOKEN for auto-login within the SDK.
// Below is an Example Code
let attributes = GenuinEmbedAttributes(embedId: YOUR_EMBED_ID, viewController: YOUR_VIEW_CONTROLLER)
let embedView = GenuinEmbedView(attributes: attributes)
self.YOUR_VIEW.addSubview(embedView)
embedView.fetchDataAndLoad()Approach 03: Initialize First, Set Attributes Second
First, create the embed view, and then assign its required attributes.
// Below is an Example Code
let embedView = GenuinEmbedView()
let attributes = GenuinEmbedAttributes(embedId: YOUR_EMBED_ID, viewController: YOUR_VIEW_CONTROLLER)
embedView.initWith(attributes: attributes)
self.YOUR_VIEW.addSubview(embedView)
embedView.fetchDataAndLoad()Approach 04: Integrating the Embed View using a Storyboard
To add the GenuinEmbedView within a Storyboard using Interface Builder, follow these steps:
- Create a Container: First, define a wrapper UIView in Interface Builder. This view will act as the container for the embed view and should be configured with your desired height and constraints.
- Add the Embed View: Drag a standard UIView and place it inside the wrapper view.
- Set the Class: In the Identity Inspector, change the class of this inner view to GenuinEmbedView.
- Specify the Module (If Needed): If the class does not automatically resolve, set the Module field (located below the Class field) to GenuinCore.
- Connect to Outlet: Create an @IBOutlet in your corresponding view controller (e.g., embedView) and connect it to the GenuinEmbedView instance in the Storyboard.
- Usage: The final step involves initializing and loading the view using the connected outlet.
@IBOutlet weak var embedView: GenuinEmbedView?
func loadEmbed() {
//specify your attributes
let attributes = GenuinEmbedAttributes(embedId: YOUR_EMEBED_ID,
viewController: YOUR_VIEW_CONTROLLER)
embedView?.initWith(attributes: attributes)
embedView?.fetchDataAndLoad()
}To initialize and load the embed, you must call the loadEmbed() function.
For more details, please refer to the additional information available here.
Full Screen Embed
let embedConfiguration = EmbedConfiguration()
embedConfiguration.isShowProfileEnabled = false
embedConfiguration.isDirectDeepLinkEnabled = false
GenuinSDK.shared.initializeEmbedFeed(embedId: "YOUR_EMBED_ID", containerView: <YOUR_CONTAINER_VIEW>, viewConroller: <YOUR_VIEW_CONTROLLER>, ssoToken: <YOUR_SSO_TOKEN>, embedConfiguration: embedConfiguration)let embedConfiguration = EmbedConfiguration()
embedConfiguration.isShowProfileEnabled = false
embedConfiguration.isDirectDeepLinkEnabled = false
GenuinSDK.shared.initializeEmbedFeed(embedId: "YOUR_EMBED_ID", containerView: <YOUR_CONTAINER_VIEW>, viewConroller: <YOUR_VIEW_CONTROLLER>, embedConfiguration: embedConfiguration)let embedConfiguration = EmbedConfiguration()
embedConfiguration.isShowProfileEnabled = false
embedConfiguration.isDirectDeepLinkEnabled = false
GenuinSDK.shared.initializeEmbedFeed(embedId: "EMBED_ID", uniqueId: "YOUR_UNIQUE_ID", containerView: YOUR_VIEW, viewConroller: YOUR_VIEW_CONTROLLER, ssoToken: "YOUR_SSO_TOKEN", params: ["name" :"FULL_NAME", "nickname" : "USER_NAME", "mobile" :"MOBILE_NO"], contextualParams: ["page_context": "CONTEXT_TEXT", "geo": { "lat": LATITUDE_VALUE, "long": LONGITUDE_VALUE }], embedConfiguration: embedConfiguration)To successfully fetch the Embed, you must include the following parameters in the function call: YOUR_EMBED_ID, YOUR_CONTAINER_VIEW (the view where the Embed will be placed), and YOUR_VIEW_CONTROLLER (the view controller containing the container view).
For an auto-login implementation, pass the YOUR_SSO_TOKEN to enable Embed with Single Sign-On (SSO) functionality in your application.
Standard Wall Embed
import GenuinCore
class StandardWallFeedViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let embedConfiguration = EmbedConfiguration()
embedConfiguration.isShowProfileEnabled = true
GenuinSDK.shared.initializeStandardWall(embedId: "YOUR_EMBED_ID", containerView: self.view, viewConroller: self, embedConfiguration: embedConfiguration)
}
}Integrating Embeds with SwiftUI
For SwiftUI implementations, you can utilize the Genuin Carousel Embed View Wrapper.
Note: When calling the function to fetch an Embed, remember to substitute YOUR_EMBED_ID with the actual ID.
For details on the Carousel Embed, refer to the Carousel View in Mobile guide.
import SwiftUI
import UIKit
import GenuinCore
struct GenuinCarouselViewWrapper: UIViewRepresentable {
var embedId: String
func makeUIView(context: Context) -> UIView {
let container = UIView()
return container
}
func updateUIView(_ uiView: UIView, context: Context) {
DispatchQueue.main.async {
guard let parentVC = uiView.parentViewController else {
print("Could not get parent VC!")
return
}
let embedConfiguration = EmbedConfiguration()
GenuinSDK.shared.initializeEmbed(
embedId: embedId,
containerView: uiView,
viewConroller: parentVC,
embedConfiguration: embedConfiguration
)
}
}
}import SwiftUI
import UIKit
import GenuinCore
struct GenuinCarouselContextViewWrapper: UIViewRepresentable {
var embedId: String
var uniqueId: String?
var ssoToken: String?
var params: [String : Any]?
var contextualParams: [String: Any]?
var embedConfiguration: EmbedConfiguration = EmbedConfiguration()
func makeUIView(context: Context) -> UIView {
let container = UIView()
return container
}
func updateUIView(_ uiView: UIView, context: Context) {
DispatchQueue.main.async {
guard let parentVC = uiView.parentViewController else {
print("Could not get parent VC!")
return
}
GenuinSDK.shared.initializeEmbed(
embedId: embedId,
uniqueId: uniqueId,
containerView: uiView,
viewConroller: parentVC,
ssoToken: ssoToken,
params: params,
contextualParams: contextualParams,
embedConfiguration: embedConfiguration
)
}
}
}Example Usage
import SwiftUI
struct CarouselView: View {
var body: some View {
VStack {
GenuinCarouselViewWrapper(embedId: "YOUR_EMBED_ID")
.frame(height: 200)
Spacer()
}
}
}
#Preview {
CarouselView()
}import SwiftUI
import UIKit
import GenuinCore
struct CarouselContextView: View {
@State private var contextualParams: [String: Any]? = nil
@State private var txtContext: String = ""
private var embedConfiguration: EmbedConfiguration = EmbedConfiguration()
init() {
let genuinCarouselConfiguration = GenuinCarouselConfiguration()
genuinCarouselConfiguration.aspectRatio = .ratio4x5
embedConfiguration.genuinCarouselConfiguration = genuinCarouselConfiguration
}
var body: some View {
VStack {
GenuinCarouselContextViewWrapper(embedId: "YOUR_EMBED_ID", uniqueId: "YOUR_UNIQUE_ID", ssoToken: "YOUR_SSO_TOKEN", params: ["name" :"FULL_NAME", "nickname" : "USER_NAME", "mobile" :"MOBILE_NO"], contextualParams: contextualParams, embedConfiguration: embedConfiguration)
.frame(height: 200)
HStack {
TextField("Contextual Params", text: $txtContext)
.textFieldStyle(.roundedBorder)
Button("Assign Context") {
contextualParams = ["page_context": txtContext, "geo" : [ "lat": LATITUDE_VALUE, "long": LONGITUDE_VALUE ]]
}
}
.padding()
Spacer()
}
}
}
#Preview {
CarouselContextView()
}Standard Wall View Wrapper
import SwiftUI
import GenuinCore
struct GenuinSDKStandardWallNavigationControllerWrapper: UIViewControllerRepresentable {
var embedId: String
func makeUIViewController(context: Context) -> UINavigationController {
// Return the UIKit UINavigationController from the SDK
let embedConfiguration = EmbedConfiguration()
return GenuinSDK.shared.getStandardWallController(embedId: embedId, embedConfiguration: embedConfiguration) ?? UINavigationController()
}
func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {
// No update logic needed unless the SDK content needs to change dynamically
}
}Example Usage
import SwiftUI
struct StandardWallView: View {
var body: some View {
GenuinSDKStandardWallNavigationControllerWrapper(embedId: "YOUR_EMBED_ID")
.edgesIgnoringSafeArea(.top)
}
}
#Preview {
StandardWallView()
}Additional EmbedConfiguration Parameters
You can customize the EmbedConfiguration by setting the following optional parameters:
- isShowProfileEnabled (Boolean)
- Default: false
- Functionality: If set to true and the user is logged in, the profile picture will appear in the full-screen view (top right corner). Clicking the profile picture will display account settings and logout options.
2. isDirectDeepLinkEnabled (Boolean)
- Default: false
- Functionality: If set to true, all interactions/clicks within the full-screen view will redirect to the specific video in the associated white-labeled app. When enabled, the value of the interactionDeepLink parameter is ignored. The regular flow is maintained if this parameter is not provided.
3. interactionDeepLink (String URL)
- Functionality: You can provide a deep-link URL here. If a valid URL is provided, all interactions/clicks in the full-screen view will redirect to this URL. The regular flow is maintained if this parameter is not provided.
- Note: The user will not be redirected if the URL is incorrect.
4. genuinCarouselConfiguration (GenuinCarouselConfiguration Object)
- Functionality: Pass a GenuinCarouselConfiguration object to modify the carousel's design. If provided, the carousel will adjust according to the configuration.
5. The default values for the GenuinCarouselConfiguration object are:
- interTileSpacing: The spacing between the carousel's collection view items.
- Default: 8.0
- viewInset: The edge insets for the carousel's collection view.
- Default: UIEdgeInsets(top: 8.0, left: 16.0, bottom: 0.0, right: 16.0)
- tileCornerRadius: The corner radius for the carousel's collection view items.
- Default: 8.0
Note: Remember to include YOUR_EMBED_ID when calling the function to fetch the Embed.

The following parameters are optional when configuring the SDK:
params Key (Optional User Information)
These parameters are used primarily for user sign-up/login:
- name: string - Recommended for user sign-up/login.
- mobile: string - Recommended for user sign-up/login.
- email: string - Recommended for user sign-up/login.
- nickname: string - If a nickname is available in the Genuin ecosystem, it will be used; otherwise, Genuin will auto-generate one.
- profile_image: string - Pass the URL of the profile image you want to display within the SDK.
contextualParams Key (Optional Feed Context)
These parameters are used to load the content feed based on specific contextual data:
- page_context: string - Pass this string to load the feed based on a specific context.
- lat: float - Latitude for geo-location-based feed loading.
- long: float - Longitude for geo-location-based feed loading.
Note: To implement a contextual feed based on location, both the lat and long parameters must be provided together.
GenuinSDK.shared.initializeEmbed(embedId: "EMBED_ID", uniqueId: "YOUR_UNIQUE_ID", containerView: YOUR_VIEW, viewConroller: YOUR_VIEW_CONTROLLER, ssoToken: "YOUR_TOKEN", params: ["name" :"FULL_NAME", "nickname" : "USER_NAME", "mobile" :"MOBILE_NUMBER"], embedConfiguration: embedConfiguration)GenuinSDK.shared.initializeEmbed(embedId: "EMBED_ID", uniqueId: "YOUR_UNIQUE_ID", containerView: YOUR_VIEW, viewConroller: YOUR_VIEW_CONTROLLER, ssoToken: "YOUR_TOKEN", contextualParams: ["page_context": "CONTEXT_TEXT", "geo": { "lat": LATITUDE_VALUE, "long": LONGITUDE_VALUE }], embedConfiguration: embedConfiguration)Placement with Swift
Before proceeding with the Carousel Embed implementation, please ensure you have completed the installation steps.
Migration Note: If you are migrating from GenuinSDK 1.0 to 2.0, you must replace import GenuinSDK with import GenuinCore throughout your codebase.
Introducing GenuinPlacementAttributes
We have introduced a new attribute, GenuinPlacementAttributes, which is essential for holding all the necessary data required to create and initialize a placement view.
You can initialize GenuinPlacementAttributes using the following parameters:
Note: The parameters mentioned above can also be passed within GenuinEmbedAttributes.
init(
placementId: String,
styleId: String,
uniqueId: String? = nil,
viewController: UIViewController,
ssoToken: String? = nil,
params: [String: Any]? = nil,
contextualParams: [String: Any]? = nil,
placementConfiguration: PlacementConfiguration = PlacementConfiguration()
)Parameters
The GenuinPlacementView initialization uses the following parameters:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
| placementId | String | Required | The identifier for the specific placement. |
| styleId | String | Required | The identifier for the desired placement style. |
| viewController | String? (optional) | Required | The parent view controller that will handle the presentation of the placement. |
| uniqueId | UIViewController | Optional | A unique identifier for this particular instance of the placement. |
| ssoToken | String? (optional) | Optional | A Single Sign-On token used for authentication purposes. |
| params | [String: Any]? (optional) | Optional | A dictionary of additional parameters for customizing the placement's behavior. |
| contextualParams | [String:[String: Any]? (optional) Any]? (optional) | Optional | Context-specific parameters relevant to the placement's content. |
| placementConfiguration | PlacementConfiguration (optional) | Optional | A custom configuration object. By default, a new PlacementConfiguration instance is used. |
Creating and Loading a Placement
A GenuinPlacementView can be created and loaded using the following method:
Approach 01: Initialize Placement
Start by initializing the placement using the required parameters.
let placementConfiguration = PlacementConfiguration()
GenuinSDK.shared.initializePlacement(
placementId: "PLACEMENT_ID",
styleId: "STYLE_ID",
containerView: YOUR_CONTAINER_VIEW,
viewController: YOUR_CONTROLLER,
contextualParams: [
"page_context": "<PAGE_CONTEXT>",
"geo": [
"lat": XX.XXX, // Float or Double
"long": XX.XXX, // Float or Double
"radius_limit": <RADIUS_LIMIT> // Int
],
"place": [
"country": "<COUNTRY_CODE>",
"state": "<STATE>",
"city": "<CITY>",
"zipcode": <ZIP> // Int
],
"time": <timestamp>, // Long
"user_segments": [
"age": "<AGE>",
"min_age": "<MIN_AGE>",
"max_age": "<MAX_AGE>",
"segment": "<SEGMENT>",
"gender": "M/F/O",
"race": "<RACE>"
],
"url": "https://url/",
"brands_ids": [
brandId1, // Int
brandId2 // Int
],
"user_interests": [""],
"posted_by_user_ids": [
"user_id1",
"user_id2"
],
"previous_page_context": "<PREVIOUS_PAGE_CONTEXT>",
"user_context": "<CONTEXT>"
],
placementConfiguration: placementConfiguration
)Approach 02: Initializing with Attributes
For this method, you first create the GenuinPlacementAttributes object and then pass it directly when initializing the placement view.
let attributes = GenuinPlacementAttributes(
placementId: "YOUR_PLACEMENT_ID",
styleId: "YOUR_PLACEMENT_STYLE_ID",
viewController: YOUR_VIEW_CONTROLLER
)
let placementView = GenuinPlacementView(attributes: attributes)
self.YOUR_VIEW.addSubview(placementView)
placementView.fetchDataAndLoad()Approach 3: Initialization Followed by Attribute Assignment
This method involves creating the placement view first, and then subsequently setting its attributes.
let placementView = GenuinPlacementView()
let attributes = GenuinPlacementAttributes(
placementId: "YOUR_PLACEMENT_ID",
styleId: "YOUR_PLACEMENT_STYLE_ID",
viewController: YOUR_VIEW_CONTROLLER
)
placementView.initWith(attributes: attributes)
self.YOUR_VIEW.addSubview(placementView)
placementView.fetchDataAndLoad()Approach 04: Integrating the Placement View via Storyboard
Follow these steps to add the GenuinPlacementView using Interface Builder:
- Create a Wrapper View: In Interface Builder, start by creating a container UIView (a wrapper view) to define the preferred height and constraints for the placement. This wrapper will house the GenuinPlacementView.
- Add the Placement View: Drag a standard UIView into your wrapper view.
- Set the Class: In the Identity Inspector, set the class of this new view to GenuinPlacementView.
- Specify the Module (If Needed): If the module for GenuinPlacementView does not automatically populate, enter GenuinCore in the Module field, which is located below the Class field.
- Connect the Outlet: Establish a connection to this view in your view controller by creating an @IBOutlet (e.g., placementView).
- Usage Example: Initialize and load the view using the connected Outlet.
@IBOutlet weak var placementView: GenuinPlacementView?
func loadPlacement() {
let attributes = GenuinPlacementAttributes(
placementId: "YOUR_PLACEMENT_ID",
styleId: "YOUR_PLACEMENT_STYLE_ID",
viewController: YOUR_VIEW_CONTROLLER
)
placementView?.initWith(attributes: attributes)
placementView?.fetchDataAndLoad()
}The loadPlacement() function must be called to initialize and load the placement.
Loading Embed and Placement Views in the Background
Data for an embed or placement view can be fetched in the background as required. Once the data is ready, you can then add the view to your view hierarchy.
Example: Loading an Embed in the Background
let embedView = GenuinEmbedView()
let attributes = GenuinEmbedAttributes(
embedId: YOUR_EMBED_ID,
viewController: YOUR_VIEW_CONTROLLER
)
embedView.initWith(attributes: attributes)
embedView.fetchDataInBackground { success in
if success {
self.YOUR_VIEW.addSubview(embedView)
embedView.load()
}
}Example: Loading a Placement in the Background
let placementView = GenuinPlacementView()
let attributes = GenuinPlacementAttributes(
placementId: "YOUR_PLACEMENT_ID",
styleId: "YOUR_PLACEMENT_STYLE_ID",
viewController: YOUR_VIEW_CONTROLLER
)
placementView.initWith(attributes: attributes)
placementView.fetchDataInBackground { success in
if success {
self.YOUR_VIEW.addSubview(placementView)
placementView.load()
}
}Auto-Login Approach for Handling User Authentication
To enable Auto-Login functionality within the SDK, you must invoke the designated method immediately after a user successfully logs into your application.
Important Note: This method call is unnecessary if you have already implemented the "Embed With SSO" feature.
GenuinSDK.shared.ssoLogin(ssoToken: "YOUR_SSO_TOKEN")Handle AutoLogin in Embed
GenuinSDK.shared.initializeEmbed(embedId: "EMBED_ID", uniqueId: "YOUR_UNIQUE_ID", containerView: YOUR_VIEW, viewConroller: YOUR_VIEW_CONTROLLER, ssoToken: "YOUR_SSO_TOKEN", params: ["name" :"FULL_NAME", "nickname" : "USER_NAME", "mobile" :"MOBILE_NO"], contextualParams: ["page_context": "CONTEXT_TEXT", "geo": { "lat": LATITUDE_VALUE, "long": LONGITUDE_VALUE }], embedConfiguration: embedConfiguration)GenuinSDK.shared.ssoLogin(ssoToken: "YOUR_SSO_TOKEN", params: ["name" :"FULL_NAME", "nickname" : "USER_NAME"])GenuinSDK.shared.ssoLogin(ssoToken: "YOUR_SSO_TOKEN") { status in
}
// Where status of login = true or falseImplementing Custom Login
To manage the login process according to your specific requirements, proceed as follows:
Assign the Delegate: When initializing the Genuin SDK, you must assign the appropriate delegate.
GenuinSDK.shared.delegate = self ( YOUR_ANY_CLASS )Step 2: Extend GenuinDelegate & Present your own controller on provided base controller
extension YOUR_ANY_CLASS : GenuinDelegate{
func presentLoginViewController(baseViewController : UIViewController) {
guard let loginVC = GET AND ASSIGN YOUR CONTROLLER
baseViewController.present(loginVC, animated: true)
}
}Step 3: Must call below login service from Genuin, to keep the user logged in, in Genuin SDK.
GenuinSDK.shared.ssoLogin(ssoToken: "YOUR_SSO_TOKEN", params: ["name" : "FULL_NAME", "nickname" : "USER_NAME"])Handling Logout with AutoLogin
To log out a user from your application, you must call the designated method after the user initiates the logout action.
GenuinSDK.shared.ssoLogout()GenuinSDK.shared.ssoLogout { status in
}
// Where status of logout = true or falseHandling Deep Links
Prerequisites:
To handle deep links, ensure you have completed the following steps (in addition to the standard SDK installation):
- White Labeling: Your community must be white-labeled. Refer to these steps for instructions.
- Associated Domains: Enable Associated Domains in the Certificates, Identifiers & Profiles section of your Apple Developer account at https://developer.apple.com/account/resources/identifiers/list.
- AASA File: Create the apple-app-site-association file (no extension) with the required settings.
{"appclips":{"apps":["YOUR_TEAM_ID.APP_BUNDLE_ID.Clip"]},"applinks":{"apps":[],"details":[{"paths":["/*"],"appID":"YOUR_TEAM_ID.APP_BUNDLE_ID"}]}}Host the created file on your white-labeled domain at:
https://YOUR_WHITE-LABELLED_DOMAIN/.well-known/apple-app-site-association
Integration Steps:
Ensure "Associated Domains" are added to your app's capabilities (if not already present).

To enable deep linking in your application, you must add the appropriate applinks entries to your domain configuration.
Example Domain Entries:
applinks: YOUR\_WHITE-LABELLED\_DOMAIN
applinks: www.YOUR\_WHITE-LABELLED\_DOMAIN
Once configured, utilize the provided methods within your app to process and handle the incoming deep links.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
handleGenuinDeeplink(deeplinkURL: connectionOptions.userActivities.first?.webpageURL)
}
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
//redirect if genuin SDK handles the deeplink
handleGenuinDeeplink(deeplinkURL: userActivity.webpageURL)
}
func handleGenuinDeeplink(deeplinkURL: URL?) {
if let dlURL = deeplinkURL, GenuinSDK.shared.willHandleDeepLink(url: dlURL){
if let rootVC = window?.rootViewController as? UIViewController{
DispatchQueue.main.async {
GenuinSDK.shared.handleDeeplink(viewController: rootVC)
}
}
}
}
}func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool {
//redirect if genuin SDK handles the deeplink
if let dlURL = userActivity.webpageURL , GenuinSDK.shared.willHandleDeepLink(url: dlURL){
if let rootVC = window?.rootViewController as? UIViewController {
GenuinSDK.shared.handleDeeplink(viewController: rootVC)
}
}
return true
}Deep Link Handling with GenuinSDK
The GenuinSDK provides methods to manage deep links within your iOS application.
Checking Deep Link Eligibility:
Use GenuinSDK.shared.willHandleDeepLink(url: dlURL) to determine if the GenuinSDK is configured to handle the provided deep link URL (dlURL). Integrate this check into your application's deep link redirection flow as needed.
Handling Deep Links:
The primary function for processing a deep link is GenuinSDK.shared.handleDeeplink(viewController: rootVC).
- In SceneDelegate: Call GenuinSDK.shared.handleDeeplink(viewController: rootVC) using your application's root view controller (rootVC).
- In AppDelegate: Use GenuinSDK.shared.handleDeeplink(viewController: rootVC) to manage the deep link via the application's root view controller (rootVC).
Important Notes:
- To handle a deep link from a view controller other than the root, call GenuinSDK.shared.handleDeeplink(viewController: vc) from that specific controller (vc).
- If you are implementing the SceneDelegate method, ensure you call GenuinSDK.shared.handleDeeplink(viewController: self) within the appropriate SceneDelegate method.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
GenuinSDK.shared.handleDeeplink(viewController: self)
}Optional: Intercepting Linkout Clicks
To intercept Linkout clicks, you need to implement the GenuinLinkOutInterceptorDelegate.
Assign the GenuinLinkOutInterceptorDelegate as the delegate:
GenuinSDK.shared.registerLinkoutInterceptor(associateDomains: [ARRAY_OF_ASSOCIATED_DOMAINS_HANDLED_BY_YOUR_APP], linkOutInterceptorDelegate: YOUR_ANY_CLASS)Note: The ARRAY_OF_ASSOCIATED_DOMAINS_HANDLED_BY_YOUR_APP parameter accepts a comma-separated list of associated domains supported by your application.
Examples: ["apple.com", "[https://apple.com/](https://apple.com/)", "[www.apple.com](https://www.apple.com)", "applinks:apple.com"]
The YOUR_ANY_CLASS parameter should be replaced with the class responsible for handling the delegate method.
Step 2: Implement the Callback Method
extension YOUR_ANY_CLASS : GenuinLinkOutInterceptorDelegate{
func onLinkOutIntercept(urlString: String, viewController: UIViewController?) {
/*
This callback will be triggered when user clicks on linkouts from any video and if it's domain matches the associateDomains provided.
You will receive the url clicked and a current controller so you can handle the deeplink redirection from here in your app
*/
}
}Integrating Firebase for Push Notifications
To set up push notifications using Firebase, follow these steps:
- Create a Firebase App: Follow the instructions here to create your application within the Firebase console.
- Download and Add Configuration File: Download the GoogleService-Info.plist file and include it in your Xcode project.
- Install Firebase Pod: Add the necessary pod entry to your Podfile.
pod 'FirebaseMessaging', '~> 10.24.0'To enable push notifications, you need to add the Push Notifications capability to your target. Go to your target, then select Signing & Capabilities, and click Add Capability to choose Push Notification.
import FirebaseMessaging
import GenuinCorefunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
//Assign APNS token and notify sdk
Messaging.messaging().apnsToken = deviceToken
GenuinSDK.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken, isFCMIntegrated: true)
}Note: Set the isFCMIntegrated parameter to true, as Firebase is being used.
6. Initialize
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
//Register the notification
registerForNotification()
//configure firebase
FirebaseApp.configure()
//set delegate , extend current class with MessagingDelegate
Messaging.messaging().delegate = self
}7. Place this code to take the user permission for Push Notification
func registerForNotification(){
//Take permission and register remote notification
let current = UNUserNotificationCenter.current()
current.getNotificationSettings(completionHandler: { (settings) in
if settings.authorizationStatus == .notDetermined{
self.requestForNotificationPermission()
}else if settings.authorizationStatus == .authorized {
UNUserNotificationCenter.current().delegate = self
DispatchQueue.main.async{
UIApplication.shared.registerForRemoteNotifications()
}
}
})
}
private func requestForNotificationPermission(){
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in
print(granted)
}
UIApplication.shared.registerForRemoteNotifications()
}8. Extend MessagingDelegate and Add following method:
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
if let token = fcmToken {
//fetch and register token
getInstanceID()
}
}
func getInstanceID(){
Messaging.messaging().token { token, error in
// Check for error. Otherwise do what you will with token here
if let error = error {
print("Error fetching remote instance ID: \(error)")
} else if let result = token {
print("Remote instance ID token: \(result)")
GenuinSDK.shared.registerFCMToken(token: result)
}
}
}9. To Handle the Push Notification Redirection whenever the user taps, follow the below code
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if let userInfo = response.notification.request.content.userInfo as? [String: AnyObject]{
//notify firebase
Messaging.messaging().appDidReceiveMessage(userInfo)
//check if genuin will handle notification
if GenuinSDK.shared.willHandleNotification(userInfo: userInfo){
//notify to redirect
GenuinSDK.shared.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
//notification notification
if let rootVC = window?.rootViewController as? UIViewController{
GenuinSDK.shared.handleNotifications(viewController: rootVC)
}
}
}
}10. The function GenuinSDK.shared.willHandleNotification(userInfo: userInfo) determines if the GenuinSDK should process a given notification. Implement this function as part of your notification redirection logic.
To configure the notification user interface (UI), proceed as follows:
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){
let userInfo = notification.request.content.userInfo
print("\(userInfo)")
//mention design type for notification
completionHandler([.list, .badge, .sound])
}11. If you want to handle the notification when app is opened then follow the below code
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){
let userInfo = notification.request.content.userInfo
GenuinSDK.shared.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
if let rootVC = window?.rootViewController as? UIViewController{
GenuinSDK.shared.handleNotifications(viewController: rootVC)
}
//mention design type for notification
completionHandler([.list, .badge, .sound])
}To handle notifications from a different controller, call the GenuinSDK.shared.handleNotifications(viewController: YOUR_VIEW_CONTROLLER) function.
Using APNS (Apple Push Notification Service)
To enable push notification functionality:
- Select your project target.
- Go to Signing & Capabilities.
- Add the Push Notification capability.
- Import necessary modules (as per the original text's continuation).
import GenuinCorefunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
//Assign APNS token and notify sdk
GenuinSDK.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken, isFCMIntegrated: false)
}SceneDelegate: Initialization
Note: Since Firebase is not being utilized, pass the value false to the isFCMIntegrated parameter.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
//Register the notification
registerForNotification()
}3. Place this code to take the user permission for Push Notification
func registerForNotification(){
//Take permission and register remote notification
let current = UNUserNotificationCenter.current()
current.getNotificationSettings(completionHandler: { (settings) in
if settings.authorizationStatus == .notDetermined{
self.requestForNotificationPermission()
}else if settings.authorizationStatus == .authorized {
UNUserNotificationCenter.current().delegate = self
DispatchQueue.main.async{
UIApplication.shared.registerForRemoteNotifications()
}
}
})
}
private func requestForNotificationPermission(){
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in
print(granted)
}
UIApplication.shared.registerForRemoteNotifications()
}4. To Handle the Push Notification Redirection whenever the user taps, follow the below code
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if let userInfo = response.notification.request.content.userInfo as? [String: AnyObject]{
//check if genuin will handle notification
if GenuinSDK.shared.willHandleNotification(userInfo: userInfo){
//notify to redirect
GenuinSDK.shared.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
//notification notification
if let rootVC = window?.rootViewController as? UIViewController{
GenuinSDK.shared.handleNotifications(viewController: rootVC)
}
}
}
}Notification Handling
The GenuinSDK.shared.willHandleNotification(userInfo: userInfo) function determines if the GenuinSDK should process a given notification. Incorporate this function into your notification redirection logic as needed.
To configure the notification UI:
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){
let userInfo = notification.request.content.userInfo
print("\(userInfo)")
//mention design type for notification
completionHandler([.list, .badge, .sound])
}6. If you want to handle the notification when app is opened then follow the below code
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){
let userInfo = notification.request.content.userInfo
GenuinSDK.shared.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
if let rootVC = window?.rootViewController as? UIViewController{
GenuinSDK.shared.handleNotifications(viewController: rootVC)
}
//mention design type for notification
completionHandler([.list, .badge, .sound])
}To handle a notification from a different controller, use the following function:
GenuinSDK.shared.handleNotifications(viewController: YOUR\_VIEW\_CONTROLLER)
What's Next? Explore Other SDKs
- Android SDK: Integrate the Android SDK into your ecosystem.
- Web SDK: Integrate the Web SDK into your ecosystem.
- React Native SDK: Integrate the React Native SDK into your ecosystem.
Configuration Parameters (Key Highlights)
EmbedConfiguration
- isShowProfileEnabled
- isDirectDeepLinkEnabled
- interactionDeepLink
- genuinCarouselConfiguration
Contextual Parameters
- page_context
- lat
- long
User Parameters
- name
- mobile
- nickname
- profile_image
Best Practices
- Always initialize core before dependent modules
- Keep SDK versions consistent (2.1.1)
- Use SSO for seamless user experience
- Enable contextual feeds for personalization
- Use background loading for performance optimization
- Ensure App Privacy compliance for monetization
Support
For implementation help or debugging support: support@begenuin.com