Skip to content

Commit

Permalink
fix web sdk get
Browse files Browse the repository at this point in the history
  • Loading branch information
korial29 committed Apr 28, 2023
1 parent 23c10e9 commit a2fff35
Show file tree
Hide file tree
Showing 7 changed files with 344 additions and 112 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.2]

### Fixed

- Fix web sdk get return

## [0.2.1]

### Fixed
Expand Down
5 changes: 1 addition & 4 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
* @DavidBonnemaison @korial29

package.json @DavidBonnemaison @korial29 @iadvizeponey
package-lock.json @DavidBonnemaison @korial29 @iadvizeponey
* @iadvize/dev-idz-messenger
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ example:
```js
// Init iAdvizeInternals
initIAdvizeHost('myIframeId');

// Web SDK navigate
window.iAdvizeInternals.push({
method: 'navigate',
Expand Down Expand Up @@ -141,7 +140,6 @@ window.iAdvizeInternals.push({
});

// Listen to activate result

window.addEventListener('message', ({ data: { method, activation } }) => {
if (method === 'activate') {
console.log(activation); // activation return object : success or failure
Expand All @@ -154,7 +152,6 @@ window.iAdvizeInternals.push({
});

// Listen to logout

window.addEventListener('message', ({ data: { method } }) => {
if (method === 'logout') {
// Do something after logout
Expand All @@ -164,21 +161,20 @@ window.addEventListener('message', ({ data: { method } }) => {
// Web SDK on
window.iAdvizeInternals.push({
method: 'on',
args: ['cookiesConsentChanged'],
args: ['visitor:cookiesConsentChanged'],
});

// Listen to cookiesConsentChanged result

window.addEventListener('message', ({ data: { method, value } }) => {
if (method === 'on') {
window.addEventListener('message', ({ data: { method, args, value } }) => {
if (method === 'on' && args.includes('visitor:cookiesConsentChanged')) {
console.log(value); // cookiesConsentChanged value
}
});

// Web SDK off
window.iAdvizeInternals.push({
method: 'off',
args: ['cookiesConsentChanged'],
args: ['visitor:cookiesConsentChanged'],
});

// Web SDK set
Expand All @@ -192,4 +188,11 @@ window.iAdvizeInternals.push({
method: 'get',
args: ['visitor:cookiesConsent'],
});

// Listen to cookiesConsent get
window.addEventListener('message', ({ data: { method, args, value } }) => {
if (method === 'get' && args.includes('visitor:cookiesConsent')) {
console.log(value); // cookiesConsentChanged value
}
});
```
15 changes: 11 additions & 4 deletions example/webSdkMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ window.addEventListener('message', ({ data: { method } }) => {
// Web SDK on
window.iAdvizeInternals.push({
method: 'on',
args: ['cookiesConsentChanged'],
args: ['visitor:cookiesConsentChanged'],
});

// Listen to cookiesConsentChanged result
window.addEventListener('message', ({ data: { method, value } }) => {
if (method === 'on') {
window.addEventListener('message', ({ data: { method, args, value } }) => {
if (method === 'on' && args.includes('visitor:cookiesConsentChanged')) {
console.log(value); // cookiesConsentChanged value
}
});

// Web SDK off
window.iAdvizeInternals.push({
method: 'off',
args: ['cookiesConsentChanged'],
args: ['visitor:cookiesConsentChanged'],
});

// Web SDK set
Expand All @@ -79,3 +79,10 @@ window.iAdvizeInternals.push({
method: 'get',
args: ['visitor:cookiesConsent'],
});

// Listen to cookiesConsent get
window.addEventListener('message', ({ data: { method, args, value } }) => {
if (method === 'get' && args.includes('visitor:cookiesConsent')) {
console.log(value); // cookiesConsent value
}
});
Loading

0 comments on commit a2fff35

Please sign in to comment.