Nucleus logo

iOS Integration

Installation
  1. Download and unzip the file
  2. Drag and drop NucleusSDK.xcframework in your project
  3. On the "Choose options for adding these files" screen, make sure your target is checked and "Added folders: Create groups" is selected before clicking Finish.
Import and initial configuration
  1. Import NucleusSDK in AppDelegate
  2. In the function application include the following fields:

    NucleusSDK.publicKey = "<Your-public-key>"
    NucleusSDK.idfaMode = .explicit
    NucleusSDK.locationMode = .explicit

  3. In the function application include the following fields:

    private var _nucleusPageSessionId: NucleusSDK.PageSessionId!
    Override viewDidAppear and include _nucleusPageSessionId = NucleusSDK.beginPageSession(pageId: “<name-of-the-current-view>”, referrerPageId: nil)
    Override viewDidDisappear and include NucleusSDK.endPageSession(pageSessionId: _nucleusPageSessionId)
  4. To enable scrollView, include the following in override viewDidAppear:

    NucleusSDK.setScrollView(pageSessionId: _nucleusPageSessionId, _tableView)
Engagement configuration
  1. The read-only variable NucleusSDK.engagementInfo exposes engagemnt info (if available, otherwise nil), with the following fields:

    `clusterId: String`
    `contentType: String` 
    `dayOfWeek: String`
    `genre: String`
    `score: Int`
    `timeOfDay: String`
SwiftUI
  1. Import NucleusSDK in your main file
  2. Include an AppDelegate file, and in the function application include the following fields:

    NucleusSDK.publicKey = "<Your-public-key>"
    NucleusSDK.idfaMode = .explicit
    NucleusSDK.locationMode = .explicit

  3. Use the @UIApplicationDelegateAdaptor property wrapper to tell SwiftUI to use your AppDelegate created above
  4. Import in your view file including the following:

    private var _nucleusPageSessionId: NucleusSDK.PageSessionId!
  5. Use SwiftUI lifecycle event onAppear with the following:

     _nucleusPageSessionId = NucleusSDK.beginPageSession(pageId: “<name-of-the-current-view>”, referrerPageId: nil)
  6. Use SwiftUI lifecycle event Disappear with the following:

    NucleusSDK.endPageSession(pageSessionId: _nucleusPageSessionId)