Requirements

PlatformMinimum Deployment TargetLanguageSupported OrientationsSupported Destinations
iOS13.0SwiftPortraitiPhone

Required Permissions

Required Permissions to be added in info.plist file of your application

PermissionUsage
Camera (NSCameraUsageDescription)Genuin needs permissions to open your camera and microphone. This allows Genuin to record videos that can be shared with other people.
Microphone (NSMicrophoneUsageDescription)Genuin needs permissions to open your camera and microphone. This allows Genuin to record videos that can be shared with other people.
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.
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.
Contacts (NSContactsUsageDescription)Genuin requires to sync with your contacts and provide a better experience when you wish to share your posts with them.
Location (NSLocationWhenInUseUsageDescription)Your precise location will help us suggest your community details more accurately.

Installation

Standard CocoaPods Install

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.

platform :ios, '13.0'

target 'YourProject' do
  use_frameworks!

  # Pods for YourProject

  pod "GenuinSDK", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => "1.1.10.2"

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
    end
  end
end

If you are using Xcode 16 then kindly refer the below podfile :

platform :ios, '13.0'

target 'YourProject' do
  use_frameworks!

pod "GenuinSDK", :git => "https://bitbucket.org/genuindev/genuin_sdk_ios.git", :tag => "1.1.10.1"

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
end

Example

Import the GenuinSDK module in your SceneDelegate/AppDelegate.

import GenuinSDK

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
    configuration.setCustomLoader("YOUR_LOADER", bundle: .main)
    //configuration.showNavigationBar = true - In order to show the navigation bar add this line


    // 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)
}

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.

Then you can display the home feed view controller. For example, to use it in your UITabBarController:

import UIKit
import GenuinSDK
class TabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        if let homeFeedController = GenuinSDK.shared.getHomeScreen() {
            homeFeedController.tabBarItem = UITabBarItem(title: "Community", image: UIImage(systemName: "person.3"), tag: 0)
            self.viewControllers = [homeFeedController]
        }
    }
}

To present feed from your UIViewController by clicking on UIButton:

ViewController.swift

import UIKit
import GenuinSDK

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    @IBAction func openFeed() {
        if let vc = GenuinSDK.shared.getHomeScreen() {
            vc.navigationBar.isTranslucent = false
            vc.modalPresentationStyle = .fullScreen
            self.present(vc, animated: true)
        }
    }
}

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. Refer to the below code block

// Below is an Example Code

if #available(iOS 15.0, *) {
    // Initialize the SDK with your API key and configuration
    GenuinSDK.shared.initialize(apiKey: "YOUR_API_KEY", configuration: configuration)
    if let vc = GenuinSDK.shared.getHomeScreen() {
        vc.tabBarItem = UITabBarItem(title: "Community", image: UIImage(systemName: "person.3"), tag: 3)
        self.viewControllers = [vc]
        self.selectedIndex = 0
    }
}

Embed

Note: Make sure you have followed the installation steps in order to implement the Carousel Embed.
Refer to Carousel View in Mobile
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)
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.

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.

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)

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.

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.

Standard Wall Embed

import GenuinSDK

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)
        
    }

}

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

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.

Handle SSO Login Explicitly in SDK

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.
 GenuinSDK.shared.ssoLogin(ssoToken: "YOUR_SSO_TOKEN")

Handle SSO Login in Embed


 GenuinSDK.shared.initializeEmbed(embedId: "EMBED_ID", uniqueId: "YOUR_UNIQUE_ID", containerView: YOUR_VIEW, viewConroller: YOUR_VIEW_CONTROLLER, ssoToken: "johndoe@gmail.com", params: ["name" :"John Doe", "nickname" : "john", "mobile" :"919797979797"], embedConfiguration: embedConfiguration)

Optional Parameters

Below are the optional parameters:

  1. name - This is an optional string parameter. Pass this parameter for ‘signup/login’.
  2. mobile - This is an option 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.

Note: mobile parameter will be first priority if it is passed along with email for login/signup.

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


GenuinSDK.shared.delegate = self ( YOUR_CONTROLLER )

Step 2: Extend GenuinDelegate & Present your own controller on provided base controller


extension YOUR_CONTROLLER : 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 user logged in, in Genuin SDK.


GenuinSDK.shared.ssoLogin(ssoToken: "example@gmail.com", params: ["name" : "FULL_NAME", "nickname" : "USER_NAME"])

Handle SSO Logout in SDK

Whenever user logs out from your application call the below method.

GenuinSDK.shared.ssoLogout()
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:

{"appclips":{"apps":["YOUR_TEAM_ID.APP_BUNDLE_ID.Clip"]},"applinks":{"apps":[],"details":[{"paths":["/*"],"appID":"YOUR_TEAM_ID.APP_BUNDLE_ID"}]}}

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.


func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
        //redirect if genuin SDK handles the deeplink
        if let dlURL = userActivity.webpageURL , GenuinSDK.shared.willHandleDeepLink(url: dlURL){
            
            GenuinSDK.initDeeplinkWith(url: dlURL)
            if let rootVC = window?.rootViewController as? UIViewController{
                GenuinSDK.shared.handleDeeplink(viewController: rootVC)
            }
        }
    }

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:

  1. In SceneDelegate.swift, implement the scene(_:continue:) method.
  2. Notify the SDK of the continued scene via GenuinSDK.initDeeplinkWith(url: dlURL).
  3. Handle deep links using the root view controller by calling GenuinSDK.shared.handleDeeplink(viewController: rootVC).

NOTE: To handle redirection of the deeplink , it is mandatory to call GenuinSDK.initDeeplinkWith(url: dlURL)

Instructions for AppDelegate:

  1. In AppDelegate.swift, implement the application(_:continue:restorationHandler:) method.
  2. Notify the SDK of the continued scene via GenuinSDK.initDeeplinkWith(url: dlURL).
  3. 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


override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    GenuinSDK.shared.handleDeeplink(viewController: self)
}

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


pod 'FirebaseMessaging', '~> 10.24.0'

  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


import FirebaseMessaging
import GenuinSDK

AppDelegate


func 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: Pass true value in isFCMIntegrated parameter, as we are using the Firebase.
  1. Initialize

SceneDelegate


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   
    }

  1. 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()
    }
    

  1. Extend MessagingDelegate and Add follwing 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)
            }
        }
    }

  1. 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)
                }
            }
        }
  }


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

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])
    }

  1. 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])
    }


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


import GenuinSDK

AppDelegate


func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
	//Assign APNS token and notify sdk
        GenuinSDK.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken, isFCMIntegrated: false) 

    }

Note: Pass false value in isFCMIntegrated parameter, as we are not using the Firebase.

SceneDelegate

Initialize


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let _ = (scene as? UIWindowScene) else { return }
	//Register the notification
        registerForNotification()
    }

  1. 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()
    }
    

  1. 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)
                }
            }
        }
  }


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

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])
    }

  1. 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])
    }


Note: To handle the notification from another controller call the GenuinSDK.shared.handleNotifications(viewController: YOUR_VIEW_CONTROLLER) function.

What’s next?

Support

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