Send message via FB sdk React

32 Views Asked by At

I need the ability for a user to send a message to their FB friends. I am trying to do it with FB sdk. But it only works for my account only(since I use my appID?). Other users get a window with An errror.Try again later. Is it possible to make it work for any user? Thanks

  const ShareMessenger = () => {
        const shareMessenger = () => {
          console.log('clicked')
          window.FB.ui({
            method: 'send',
            link: url
          })
        }
    
        useEffect(() => {
          window.fbAsyncInit = () => {
            window.FB.init({
              appId: 'myappid',
              autoLogAppEvents: true,
              xfbml: true,
              version: 'v11.0'
            })
          }
          ;(function (d, s, id) {
            var js,
              fjs = d.getElementsByTagName(s)[0]
            if (d.getElementById(id)) {
              return
            }
            js = d.createElement(s) as HTMLScriptElement
            js.id = id
            js.src = 'https://connect.facebook.net/en_US/sdk.js'
            fjs?.parentNode?.insertBefore(js, fjs)
          })(document, 'script', 'facebook-jssdk')
        }, [])
    
        return (
          <S.ItemContainer>
            <S.Messenger onClick={shareMessenger}>
              <Messenger />
              Messenger
            </S.Messenger>
            <p>Send on Messenger.</p>
          </S.ItemContainer>
        )
      }
0

There are 0 best solutions below