PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.3.75
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.3.75
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
← All changes | scripts/utils/backgroundAppUtils.ts +9 -3 11.3.5611.3.75 View file →
@@ -5,8 +5,10 @@
5 5 portalId,
6 6 leadinPluginVersion,
7 7 } from '../constants/leadinConfig';
8 8 import { initApp } from './appUtils';
9 +import { fetchAccessToken } from '../api/wordpressApiClient';
10 +import { isEmbedderReady } from './embedderReady';
9 11
10 12 type CallbackFn = (...args: any[]) => void;
11 13
12 14 export function initBackgroundApp(initFn: CallbackFn | CallbackFn[]) {
@@ -25,18 +27,21 @@
25 27 leadinPluginVersion,
26 28 };
27 29 };
28 30
29 -export const getOrCreateBackgroundApp = (refreshToken = '') => {
31 +export const getOrCreateBackgroundApp = (accessToken = '', expiresIn = 0) => {
30 32 if ((window as any).LeadinBackgroundApp) {
31 33 return (window as any).LeadinBackgroundApp;
32 34 }
35 + if (!isEmbedderReady()) {
36 + return null;
37 + }
33 38 const { IntegratedAppEmbedder, IntegratedAppOptions }: any = window;
34 39 const options = new IntegratedAppOptions()
35 40 .setLocale(locale)
36 41 .setDeviceId(deviceId)
37 42 .setLeadinConfig(getLeadinConfig())
38 - .setRefreshToken(refreshToken.trim());
43 + .setAccessToken(accessToken, expiresIn);
39 44
40 45 const embedder = new IntegratedAppEmbedder(
41 46 'integrated-plugin-proxy',
42 47 portalId,
@@ -44,9 +49,10 @@
44 49 () => {}
45 50 ).setOptions(options);
46 51
47 52 embedder.attachTo(document.body, false);
48 - embedder.postStartAppMessage(); // lets the app know all all data has been passed to it
53 + embedder.setTokenRenewalCallback(fetchAccessToken);
54 + embedder.postStartAppMessage(); // lets the app know all data has been passed to it
49 55
50 56 (window as any).LeadinBackgroundApp = embedder;
51 57 return (window as any).LeadinBackgroundApp;
52 58 };