0

I am using the Facebook SDK to share a post on Facebook and receive a response from Facebook indicating whether the post has been shared or not. If the post is shared, then I want to display a download button. This functionality works fine on desktop, but I never receive any response on mobile devices.

if (mediaImage7) {
        // Load the Facebook SDK asynchronously
        window.fbAsyncInit = function () {
            console.log('Facebook SDK initialized');
            FB.init({
                appId: '23477',
                status: true,
                cookie: true,
                autoLogAppEvents: true,
                xfbml: true,
                version: 'v12.0',
            });

            mediaImage7.addEventListener('click', function (e) {
                e.preventDefault();
                if (!sharedIpledge) {
                    sharedMobile = 1;
                    let urlToShare = siteName + '/ipledge-allegiance/';
                    let ipledgePicture = siteName + '/wp-content/uploads/2023/06/IPledgeAllegiance-157x300.png';
                    let ipledgeName = 'I Pledge Allegiance eBook';
                    let ipledgeDescription = 'I Pledge Allegiance eBook';
                    FB.ui(
                        {
                            method: 'share',
                            href: urlToShare,
                            display: 'popup',
                            picture: ipledgePicture,
                            caption: ipledgeName,
                            description: ipledgeDescription,
                            message: ipledgeDescription,
                        },
                        function (response) {
                            if (response && !response.error_code) {
                                sharedIpledge = true;
                                if (response) {
                                    jQuery.ajax({
                                        url: ajaxurl,
                                        data: {
                                            action: 'set_download_value_donate_section',
                                        },
                                        dataType: 'json',
                                        method: 'POST',
                                        success: function (response) {
                                            if (response.msg) {
                                            } else {
                                            }
                                        },
                                        error: function (e) {
                                            console.log('AJAX Error:', e);
                                        },
                                    });
                                } else {
                                }
                                appendDownloadButton(mediaImage7);
                            }
                        }
                    );
                }
            });
        };
    }
1
  • "If the post is shared, then I want to display a download button." - you are not allowed to "reward" the user for sharing. developers.facebook.com/docs/apps/examples-developer-policy-3.2: "Don't incentivize people to post content on Facebook, or give the impression that posting to Facebook will be rewarded. For example, don’t give people anything in exchange for them posting to Facebook (i.e. don’t give or promise virtual goods, achievements, coupons, discounts, access to content or extra entries in a promotion, if they post content to Facebook)."
    – CBroe
    Commented Feb 7 at 6:57

0

Browse other questions tagged or ask your own question.