Skip to main content

Initializing Nuclei SDK

Initializing Nuclei SDK

The Nuclei SDK should be initialized before using any of its features. This guide provides a recommended approach for initializing the Nuclei SDK in an Xcode project.

It is recommended to initialize the Nuclei SDK at the time of app launch. In your Xcode project, initialize the SDK in the AppDelegate under the following function:

AppDelegate.swift
import CoreAdapter

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
CoreAdapterConfig.configSetup(with: self)
}

Implementing Required Protocol Methods

Partner apps need to implement the required protocol methods. Below is an example implementation:

// Import CoreAdapter
import CoreAdapter

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
CoreAdapterConfig.configSetup(with: self)
}

// Partner App has to implement required protocol methods
extension AppDelegate: PartnerConfig {

// Environment and Identifiers
static var environment: Environment = Environment.preproduction // <end point framework pointing to>
static var partnerId: String = "abcd-1234-efg" // <specify partner-id>
static var deviceuuid: String = UIDevice.current.identifierForVendor!.uuidString // <specify device id>
static var googleMapKey: String = "" // "Google MapKey" <----- OPTIONAL Only if client is using cabs framework>

// Primary Colors
static var primaryColor: UIColor = UIColor.blue // <specify the color to common components>
static var barTintColor: UIColor = UIColor.blue // <specify bar tint color>
static var tintColor: UIColor = UIColor.white // <specify bar button tint color>

// Status and Title Colors
static var statusBarColor: UIColor = isStatusBarDark ? (UIViewController().isDarkMode ? UIColor.black : UIColor.white) : UIColor.white
static var titleColor: UIColor = UIColor.white // <specify navigation bar title color>

// Button Colors
static var buttonTextColor: UIColor = UIColor.white // <specify button text color>
static var buttonBackgroundColor: UIColor = UIColor.purple // <specify button background color>

// Text Colors
static var labelTextColor: UIColor = UIColor.blue
static var textFiledTextColor: UIColor = UIColor.black
static var unSelectedTabTextColor: UIColor = UIColor.blue // <specify the color for unselected tab text color>

// Background and Icon Colors
static var labelBackgroundColor: UIColor = UIColor.systemTeal
static var searchCardBackgroundColor: UIColor = UIColor.groupTableViewBackground // <specify background color for modify search>
static var infoIconColor: UIColor = UIColor.blue // <specify the color to be used for info icons>

// Indicator Colors
static var tabIndicatorColor: UIColor = UIColor(hexString: "#DE5245") // <specify the tab indicator color for selected tabs>

// UI and Design
static var isStatusBarDark: Bool = true
static var translucent: Bool = false // true/false
static var isFlatDesign: Bool = true
static var isNeumorphicDesign: Bool = false
static var modalPresentationStyle: PresentationStyle = PresentationStyle.fullscreen // <specify the option>

// Localization and Deep Linking
static var preferredLocalization = PreferredLanguage.english
static var deeplinkScheme: String = "gonuclei://myapp/gonuclei" // <specify deeplink for screen navigation>

// Debug and Miscellaneous
static var enableDebug: Bool = true // true/false
static var menuOptions: [String] = ["Home", "Logout"] // <specify array three dot menu options>

func nucleiHeartBeat() {
print("Heart beat triggered")
// Heart beat handling for the client must be taken here
}

func menuOptionTapped(_ index: Int, _ title: String) {
if title == "Home" {
CoreAdapter.dissmissNuclei(animated: true) {}
} else if title == "Logout" {
CoreAdapter.logout() {
print("Logout")
}
}
}
}

Property Descriptions

  • environment: The endpoint that the SDK is going to point to. Possible endpoints are production, preproduction, and staging.
  • partnerId: Specify the Partner ID. If you don't have one, please request it from the relevant source.
  • barTintColor: Specify the UINavigationBar tint color.
  • tintColor: Specify the UIBarButton tint color. Default color is white.
  • titleColor: Specify the UINavigationBar title color. Default color is white.
  • translucent: A Boolean value indicating whether the navigation bar is translucent (true) or not (false).
  • buttonTextColor: Specify the UIButton text color. Default color is black.
  • buttonBackgroundColor: Specify the UIButton background color. Default color is white.
  • deeplinkScheme: Specify the deeplink for screen navigation (e.g., gonuclei://myapp/gonuclei). The last path component should be gonuclei. For more information, For more information refer Defining a Custom URL Scheme
  • deviceuuid: Specify the user device ID, which is required by Nuclei SDK to uniquely identify the device.
  • menuOptions: Specify the menu options that will be shown in SDK screens (e.g., ["Home", "Logout"]). Callbacks should be handled by the partner app.
  • preferredLocalization: Specify the language to support localization. Supported languages are English and Arabic.
  • enableDebug: Enable or disable debug logs.
  • modalPresentationStyle: Configure the presentation style. Default is full screen.
  • searchCardBackgroundColor: Specify the background color for modify search.
  • primaryColor: Specify the image tint color.
  • infoIconColor: Specify the info icon color.
  • unSelectedTabTextColor: Specify the color to be used for unselected tab text color.
  • tabIndicatorColor: Specify the color to be used as a tab indicator color for selected tab items.
  • googleMapKey: This is optional and should only be initialized if the client is using the Cabs category.

Functions

  • nucleiHeartBeat(): Function for handling user sessions. This function provides a callback to the client for session handling.
  • menuOptionTapped(_ index: Int, _ title: String): Function for handling three-dot menu options. If the client specifies an array of menu options like “Home” or “Logout” in static var menuOptions: [String], then these options must be handled in this function.

By following this guide, you can ensure that the Nuclei SDK is properly initialized and configured in your app.