meta embed fixes
This commit is contained in:
parent
ce293be095
commit
18cc0a1154
3 changed files with 20 additions and 5 deletions
|
|
@ -49,6 +49,7 @@ def signup_public_config(db: Session) -> dict[str, Any]:
|
|||
"app_id": app_id or None,
|
||||
"config_id": config_id or None,
|
||||
"api_version": settings.whatsapp_api_version,
|
||||
"sdk_version": "v26.0",
|
||||
"ready": bool(app_id and config_id and secret),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -1126,6 +1126,7 @@ export type WhatsAppSignupConfig = {
|
|||
app_id: string | null
|
||||
config_id: string | null
|
||||
api_version: string
|
||||
sdk_version?: string
|
||||
ready: boolean
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue