Skip to content

Instantly share code, notes, and snippets.

@andresilveirah
Last active August 20, 2019 10:12
Show Gist options
  • Save andresilveirah/b1600751a8185a87947dbc437de6fb6e to your computer and use it in GitHub Desktop.
Save andresilveirah/b1600751a8185a87947dbc437de6fb6e to your computer and use it in GitHub Desktop.

onReceiveMessageData(Object msgData):

when the scenario "decides" a message should show, msgData is:

{
  msgID: 50983,
  d: { abp: false, abt: false },
  o: { wl: false, oir: false },
  ci: { comp: false, src: 0 },
  u: { uuid: "3febf9dc-af84-42b8-ab23-9325bcf68ad7", bucket: 554 },
  info: {
    cmpgn_id: 36601,
    prtn_uuid: "6f1676b8-fe6c-4678-be1c-a8c8808e0583",
    msg_id: 50983,
    msg_desc: "Simple Message"
  }
}

when no message will show: same thing but msgID is 0 and info.msg_desc is ""

Ideally this function shouldn't be called when no message is going to be displayed. In the case, we should call onConsentReady right away instead.

In the case when there's a message to be shown, then this function would be called. The msgData object is not necessary for the SDK, we just use it to check if msgID is 0 (meaning no message will be displayed).

onMessageChoiceSelect(Number type):

According to Matt Angelini, type is one of:

export const CHOICE_NAMES_READABLE = {
  1: 'White List',
  2: 'Recovery',
  3: 'Alt Ad - Video',
  4: 'Custom',
  5: 'Redirect',
  6: 'Continue with Adblocker',
  7: 'Alt Pay',
  8: 'Login',
  9: 'Custom Javascript',
  10: 'Welect',
  11: 'Accept All',
  12: 'Show Privacy Manager',
  13: 'Reject All',
  14: 'Samba',
};

So far we've only seen 11, 12 and 13.

If you find better to change from number to strings ("Accept All" instead of 11), that's ok too.

onPrivacyManagerChoiceSelect(Object pmData):

When the user clicks on Save & Exit, Accept All or Reject All, pmData will be:

{
  purposeConsent: "all" | "some" | "none",
  vendorConsent: "all" | "some" | "none",
  vendorList: undefined // don't know why this is undefined :(
}

Notice the Cancel button does not trigger the this method.

onMessageChoiceError(Object error):

I believe this is a "catch all" that gets called whenever there's an error within the client js. A common use case for the SDKs is to detect when the user looses Internet connection and clicks on Show Options, this function will be called when the SDK will dismiss the webviews and notify the app something went wrong.

We don't rely on the content of the error object itself, only that it's an object.

onConsentReady(String consentUUID, String euconsent):

I believe would behave similar to the mysterious sendConsentData. This function would mean the user is done interacting with either the Message or the PM (by accepting, rejecting or dismissing). consentUUID is (for the SDKs purposes) any non-empty String and euconsent needs to be a valid consent string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment