Swift Module: PersistentData

Swift Module: PersistentData

by ‎12-22-2017 06:36 AM - edited ‎05-29-2018 01:31 AM (584 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

External Dependencies

Foundation

Recommended Usage

Usage of this module is recommended.

It is automatically included in Carthage and CocoaPods framework builds.

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

Retrieves variables from 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()?.deleteData(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

Build 1

  • Initial release