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

@ -49,6 +49,7 @@ def signup_public_config(db: Session) -> dict[str, Any]:
"app_id": app_id or None, "app_id": app_id or None,
"config_id": config_id or None, "config_id": config_id or None,
"api_version": settings.whatsapp_api_version, "api_version": settings.whatsapp_api_version,
"sdk_version": "v26.0",
"ready": bool(app_id and config_id and secret), "ready": bool(app_id and config_id and secret),
} }

View file

@ -52,7 +52,15 @@ function loadFacebookSdk(): Promise<void> {
if (facebookSdk()) return Promise.resolve() if (facebookSdk()) return Promise.resolve()
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const host = window as Window & { fbAsyncInit?: () => void } 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 if (document.getElementById('facebook-jssdk')) return
const script = document.createElement('script') const script = document.createElement('script')
script.id = 'facebook-jssdk' script.id = 'facebook-jssdk'
@ -273,9 +281,9 @@ export function WhatsAppSetupPage() {
if (!sdk) throw new Error('Meta sign-in did not initialize') if (!sdk) throw new Error('Meta sign-in did not initialize')
sdk.init({ sdk.init({
appId: config.app_id, appId: config.app_id,
cookie: true, autoLogAppEvents: true,
xfbml: false, xfbml: true,
version: config.api_version, version: config.sdk_version || 'v26.0',
}) })
sdk.login( sdk.login(
(response) => { (response) => {
@ -301,8 +309,8 @@ export function WhatsAppSetupPage() {
response_type: 'code', response_type: 'code',
override_default_response_type: true, override_default_response_type: true,
extras: { extras: {
version: 'v4',
setup: {}, 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.' ? '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.'} : 'Embedded Signup is not available until the Meta configuration id is set for this environment.'}
</small> </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> </section>
<aside className="wa-biz-aside"> <aside className="wa-biz-aside">
<h3>Why connect?</h3> <h3>Why connect?</h3>

View file

@ -1126,6 +1126,7 @@ export type WhatsAppSignupConfig = {
app_id: string | null app_id: string | null
config_id: string | null config_id: string | null
api_version: string api_version: string
sdk_version?: string
ready: boolean ready: boolean
} }