Giter Site home page Giter Site logo

ios-sdk's Introduction

iOS-SDK

A simple framework for firing MediaMath Pixels

Usage

The SDK has four static reporting functions:

  • report(advertiser: Int, pixel: Int, addlParams: String?)

  • report(advertiser: String, pixel: String, addlParams: String?)

  • report(advertiser: Int, pixel: Int, addlParams: [String: String])

  • report(advertiser: String, pixel: String, addlParams: [String: String])

    • advertiser : TerminalOne Advertiser ID (value from &mt_adid= of a JS pixel from a website)
    • pixel : TerminalOne Pixel ID (value from &mt_id= of a JS pixel from a website)
    • addlParams : Additional information to send to TerminalOne at the time of pixel fire (see 'The addlParams argment')

The addlParams argument

addlParams may be passed in as a [String: String] dictionary or as a URL-encoded string of parameters joined by ampersand characters (e.g."v1=data1&v2=data2&s1=data3") It may be omitted from function calls if not needed. Advertisers typically use these in scenarios such as the following: The addlParams may be used in the following ways:

  • Revenue tracking: To send a pixel tracking the value of an order, include something like v1=99.99&s1=USD.
  • Deterministic reinforcement: include a mt_exem or mt_excl argument
    • The value for the mt_exem (for hashed emails, '[email protected]') or the mt_excl (for hashed account ids, e.g. 'john2015', '829852', etc) must be SHA-256 hashed at the time of pixel firing
    • When using addlParams: [String: String], the value of mt_excl is automatically hashed. The value of mt_exem is hashed if it contains an '@' character (i.e. if it is an email address)
    • When using addlParams: String, hashing is not performed by the MediaMath Pixel SDK. The app developer must SHA-256 hash the value.
    • For more information, see the API docs on mobile pixels.
  • For more information on additional parameters, consule the Knowledge Base.

Debugging

There is a setDebugOutput(debug: Bool) function for enabling the printing of debug output to console.

Example App

Check out the MMPixelExampleApp for a simple implementation of the framework.

ios-sdk's People

Contributors

mtjoe avatar pswaminathan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-sdk's Issues

Code Review

More Important (functionality/types):

  • What’s the advantage of making addlParams a string over a [String: String]? (Besides backward compatibility)
  • Can we add in functionality to hash an email address if it comes in? e.g. let’s just see if mt_exem has anything other than [a-f0-9] and hash it for them
  • Classes vs structs: structs are simpler and should be preferred. Further, structs have value semantics, while classes have reference semantics. Unless you need reference semantics (like identity), or additional class features (like inheritance that can’t be accomplished through composition, or deinitializers), use a struct. Whether MMPixel (née MMPixelSdk) should be a class or a struct is up for debate. But definitely MMPixelConfig, which is just a collection of values, and UserAgent, which is a by-device value, should be structs

Less Important (style/naming):

  • Do we need to name the class Sdk? The body of code is the SDK. The class should be the object. In this case, the object is a MediaMath pixel, so why not just name the class MMPixel?
  • “Sdk” should be “SDK” in the framework name—initialisms should be capitalized throughout
  • Colons should have one space on the right and none on the left:
    • let headers: [String : String] = ["User-Agent": userAgentStr]
    • func getPixelUrl(advertiser: Int, pixel: Int, addlParams : String?) -> String {
    • static let MM_MATHTAG_URL:String = "https://pixel.mathtag.com/event/mob?mt_adid=%d&mt_id=%d&mt_time=%lu&mt_idt=idfa"
      static let MM_MAX_NUMBER_RETRIES:Int = 5
      static let MM_CONNECTION_TIMEOUT:Int = 5
      static let MM_CONNECTION_RETY_DELAY:Int = 5
      static let MM_CONNECTION_MAX_FAILED_RETRIES:Int = 2
      static let MM_DEBUG:Bool = false
  • I’m partial to not using all capitals in constant names (
    static let MM_MATHTAG_URL:String = "https://pixel.mathtag.com/event/mob?mt_adid=%d&mt_id=%d&mt_time=%lu&mt_idt=idfa"
    static let MM_MAX_NUMBER_RETRIES:Int = 5
    static let MM_CONNECTION_TIMEOUT:Int = 5
    static let MM_CONNECTION_RETY_DELAY:Int = 5
    static let MM_CONNECTION_MAX_FAILED_RETRIES:Int = 2
    static let MM_DEBUG:Bool = false
    static let MM_FRAMEWORK_NAME = "MMPixelSdk"
    static let MM_FRAMEWORK_VERSION = "1.0"
    ). This tends to be the community consensus too as far as I can see.
    • Use MathTagURL, MaxRetries, MaxConnectionTimeout, etc.
    • You also don’t need the MM prefix—we already have that because the class is named MMPixelConfig!

Port SDK to Swift 4.2

SDK is currently built in Swift 3 and throwing errors and throwing errors when client is trying to build using Swift 4.2. Submitting request to update SDK to support 4.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.