meta embed fixes

This commit is contained in:
debu-2 2026-10-07 23:43:59 +05:30
parent ce293be095
commit 18cc0a1154
3 changed files with 20 additions and 5 deletions

View file

@ -52,7 +52,15 @@ function loadFacebookSdk(): Promise<void> {
if (facebookSdk()) return Promise.resolve()
return new Promise((resolve, reject) => {
const host = window as Window & { fbAsyncInit?: () => void }
host.fbAsyncInit = () => resolve()
const previous = host.fbAsyncInit
host.fbAsyncInit = () => {
previous?.()
resolve()
}
if (facebookSdk()) {
resolve()
return
}
if (document.getElementById('facebook-jssdk')) return
const script = document.createElement('script')
script.id = 'facebook-jssdk'
@ -273,9 +281,9 @@ export function WhatsAppSetupPage() {
if (!sdk) throw new Error('Meta sign-in did not initialize')
sdk.init({
appId: config.app_id,
cookie: true,
xfbml: false,
version: config.api_version,
autoLogAppEvents: true,
xfbml: true,
version: config.sdk_version || 'v26.0',
})
sdk.login(
(response) => {
@ -301,8 +309,8 @@ export function WhatsAppSetupPage() {
response_type: 'code',
override_default_response_type: true,
extras: {
version: 'v4',
setup: {},
sessionInfoVersion: '3',
},
},
)
@ -398,6 +406,11 @@ export function WhatsAppSetupPage() {
? 'Setup usually takes a few minutes. Meta decides which businesses, accounts, and numbers you can use.'
: 'Embedded Signup is not available until the Meta configuration id is set for this environment.'}
</small>
{config?.ready && (
<small>
If Meta shows “JSSDK Option is Not Toggled”, turn on Login with the JavaScript SDK under Facebook Login for Business → Settings, and add this site’s HTTPS domain to Allowed domains and Valid OAuth redirect URIs.
</small>
)}
</section>
<aside className="wa-biz-aside">
<h3>Why connect?</h3>