Swift Module: PersistentData

Swift Module: PersistentData

by ‎12-22-2017 06:36 AM - edited ‎11-29-2018 12:42 PM (859 Views)

Purpose

Allows data variables to be stored on disk, and automatically adds them to each dispatch/tracking call. Please note, this module cannot be used on its own; it can only be used in conjunction with either the File Storage or DefaultsStorage module.

Supported Platforms

  • iOS
  • tvOS
  • watchOS
  • macOS

Installation

The PersistentData module is bundled with both the FileStorage and DefaultsStorage modules. You should choose one of these modules only.

CocoaPods

Framework will be auto-instantiated, so long as the pod is installed. Depends on TealiumCore pod. No additional import statements necessary besides import TealiumSwift.

pod 'tealium-swift/TealiumFileStorage OR pod 'tealium-swift/TealiumDefaultsStorage as required

Carthage

Framework will be auto-instantiated, so long as it is compiled into your app (included in "Embedded Binaries"). Depends on TealiumCore.

TealiumFileStorage.framework OR TealiumDefaultsStorage.framework import TealiumFileStorage OR import TealiumDefaultsStorage // required if you need to store persistent data

Recommended Usage

Usage of this module is recommended.

Included Variables

No additional variables are introduced by this module.

Public API

add

Adds variables to the persistent data store

add(data:[String:Any])

Parameters Description Example Value
data Dictionary of key/value pairs to add to persistent data ["somekey": "somevalue"]
// SAMPLE
// assuming 'tealium' initialized earlier
tealium?.persistentData()?.add(data: ["customer_id":"1234567890-a"])

getData

Adds variables to the persistent data store

getData()

// SAMPLE
// assuming 'tealium' initialized earlier
let data = tealium?.persistentData()?.getData()

deleteData

Deletes data for a specific set of known keys from the persistent data store

deleteData(forKeys:[String])

Parameters Description Example Value
forKeys [String] array of keys to delete. ["somekey", "someotherkey"]
// SAMPLE
// assuming 'tealium' initialized earlier
tealium?.persistentData()?.deleteDate(forKeys: ["customer_id"])

deleteAllData

Deletes all data in the persistent data store

deleteAllData()

// SAMPLE
// assuming 'tealium' initialized earlier
tealium?.persistentData()?.deleteAllData()

Future Improvements

No planned changes

Change Log

1.6.5

  • Now bundled by default with DefaultsStorage and FileStorage modules
  • Bug fix for potential memory leak

Build 1

  • Initial release