Facebook Checkbox plugin was hidden - facebook-javascript-sdk

I have try to add checkbox plugin but it was hidden.
Please help me resolve that problem.
Thanks,
<script>
window.fbAsyncInit = function () {
FB.init({
appId: '365440040557177',
xfbml: true,
version: 'v2.6'
});
FB.Event.subscribe('messenger_checkbox', function (e) {
console.log("messenger_checkbox event");
console.log(e);
if (e.event == 'rendered') {
console.log("Plugin was rendered");
} else if (e.event == 'checkbox') {
var checkboxState = e.state;
console.log("Checkbox state: " + checkboxState);
} else if (e.event == 'not_you') {
console.log("User clicked 'not you'");
} else if (e.event == 'hidden') {
console.log("Plugin was hidden");
}
});};
</script>

If the allow_login parameter is set to false, you will need to have a valid Facebook user session (i.e. not logged in as a page) otherwise the plugin will be hidden.

Related

How to call function on XMLHttpRequest status = true in Vue 2? I get "this.xxxx not a function" error

I have the following code, which works fine except for the "makeToast" function that I'm trying to call when status response is true. I get a "this.makeToast is not a function" error on the console.
This function is working fine if I call it after the XMLHttpRequest code. The data is also not being assigned to the msgForm property. I could not figure out why. The "alert(..." message work fine.
<script>
import ToastMixins from '/src/mixins/ToastMixins'
let config = {
headers: {
}
}
export default {
name: 'ModalDestaque',
mixins: [
ToastMixins
],
methods: {
myFunction() {
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log('onreadystatechange');
console.log('responseText 1', xhr.responseText);
this.loading = false;
if (xhr.status == 200) {
console.log('responseText 2', xhr.responseText);
let responseObj = JSON.parse(xhr.responseText);
console.log('responseObj', responseObj);
if (responseObj.status == true) {
//alert('Ok');
// this is not working:
this.msgForm = "Message success!";
this.makeToast('b-toaster-bottom-right', true, 'success');
} else {
alert('Not ok...');
}
}
}
};
}
}
}
What am I doing wrong?
I've found the solution while reading the docs at W3 Schools.
W3 Schools AJAX XMLHttp - Multiple Callback Functions
Although, I haven't found a working example anywhere.
In my code, at the button click event that triggers the XMLHttpRequest, I've added the function name "callToast" as a variable, so:
#click="onClickSubmit(myValue, myId, myTitle, callToast)"
Then in the script:
<script>
onClickSubmit(amount, id, title, cFunction) {
// stuff
if (xhr.status == 200) {
let responseObj = JSON.parse(xhr.responseText);
if (responseObj.status == true) {
// here I call the callToast function:
cFunction(this);
alert('Ok');
} else {
alert('Not ok...');
}
}
},
callToast() {
this.msgForm = "Message success!";
this.makeToast('b-toaster-bottom-right', true, 'success');
}
</script>

(AppsFlyer / ReactNative) How can I get attribution parameter from onAppOpenAttribution?

This might be a dumb question, but currently I really need a help. Can someone please help me out?
I'm implementing AppsFlyer on my ReactNative Project (Android)
What I want to do is console.log attribution parameter.
But, there are no console.logging happening.
Could someone please read my snippet and how can I access to attribution parameter, please?
or, is there any proper way to console.log attribution parameter or save it to variable?
App.tsx
​import appsFlyer from 'react-native-appsflyer';
var testFunc = appsFlyer.onAppOpenAttribution(
    (data) => {
        console.log(data);
    }
);
appsFlyer.initSdk(
    {
        devKey: '***************************',
        isDebug: false,
    },
    (result) => {
        console.log(result);
    },
    (error) => {
        console.error(error);
    },
);
const Home: React.FC<Props> = props => {
    const [appState, setAppState] = useState(AppState.currentState);
    // ! when I press device's home button (appstate changes to background),
   // ! console.log in testFunc is not working...
  
    useEffect(() => {
        function handleAppStateChange(nextAppState) {
            if (appState.match(/active|foreground/) && nextAppState === 'background') {
                if (testFunc) {
                    testFunc();
                    testFunc = null;
                }
            }
          setAppState(nextAppState);
       }
        AppState.addEventListener('change', handleAppStateChange);
        return () => {
        AppState.removeEventListener('change', handleAppStateChange);
      };
  })
To my understanding, the onAppOpenAttribution event only triggers when you already have the app installed and click on a deep link. Try to use onInstallConversionData instead and see what happens, since it triggers once the SDK is initialized. I'd also remove the "useEffect" section entirely just to test. I hope this helps.
nevermind,
I added appsFlyer.onInstallConversionData
then it worked...
import appsFlyer from 'react-native-appsflyer';
var onInstallConversionDataCanceller = appsFlyer.onInstallConversionData((res) => {
if (JSON.parse(res.data.is_first_launch) == true) {
if (res.data.af_status === 'Non-organic') {
var media_source = res.data.media_source;
var campaign = res.data.campaign;
console.log('This is first launch and a Non-Organic install. Media source: ' + media_source + ' Campaign: ' + campaign);
} else if (res.data.af_status === 'Organic') {
console.log('This is first launch and a Organic Install');
}
} else {
console.log('This is not first launch');
}
});
var onAppOpenAttributionCanceller = appsFlyer.onAppOpenAttribution((res) => {
console.log(res)
});
appsFlyer.initSdk(
{
devKey: '***************************',
isDebug: false,
},
(result) => {
console.log(result);
},
(error) => {
console.error(error);
},
);
const Home: React.FC<Props> = props => {
const [appState, setAppState] = useState(AppState.currentState);
useEffect(() => {
function handleAppStateChange(nextAppState) {
if (appState.match(/active|foreground/) && nextAppState === 'background') {
if (onInstallConversionDataCanceller) {
onInstallConversionDataCanceller();
onInstallConversionDataCanceller = null;
}
if (onAppOpenAttributionCanceller) {
onAppOpenAttributionCanceller();
onAppOpenAttributionCanceller = null;
}
}
AppState.addEventListener('change', handleAppStateChange);
return () => {
AppState.removeEventListener('change', handleAppStateChange);
};
})

react-native-firebase/admob rewardedAd.load() not working the second time

rewardedAd.load() does not load ad on the second time.
Everything works fine with the loading, showing, callbacks for the first ad shown, when I then do a rewardedAd.load() again to load another ad, nothing happens. No errors, no callbacks. Then obviously calling rewardedAd.show() rusults in a admob/not-ready error.
This problem occurs in admob/firebase versions 6.2.0 and 6.3.1
if(environment == 'development'){
rewardedAd = RewardedAd.createForAdRequest(TestIds.REWARDED)
}
else if(environment == 'production'){
rewardedAd = RewardedAd.createForAdRequest(settings.adsUnitIds.ios.real)
}
// --
rewardedAd.onAdEvent((type, error, reward) => {
console.log('onAdEvent, type:', type, ', error:', error)
if(type === RewardedAdEventType.LOADED){
dispatch({ type: 'AD_LOADED' })
}
if(type == 'closed'){ // RewardedAdEventType.CLOSED isn't defined (probably bug), so just made it "closed", which works
console.log('ad closed, rewarded:', rewarded)
if(rewarded == true){
if(!doubleReward){
dispatch(rewardCoins(settings.coins.ad, 'watched-ad'))
}
else {
dispatch(rewardCoins(settings.coins.ad*2, 'watched-ad'))
}
rewarded = false
}
dispatch({ type: 'AD_CLOSED', rewarded: rewarded })
if(showEnded) showEnded()
setTimeout(() => { // Cannot reproduce bug where re-request of ad isn't available so adding this just in case
console.log('Start ad re-request')
console.log('Do we have rewardedAd variable? :', rewardedAd)
rewardedAd.load()
}, 200)
}
if(type === RewardedAdEventType.EARNED_REWARD){
console.log('earned reward!')
dispatch({ type: 'AD_REWARDED' })
rewarded = true
}
if(type === RewardedAdEventType.ERROR){
console.info('Some error with ad:', error)
}
})
rewardedAd.load()
How about try this for auto load after shown?
rewardedAd.onAdEvent((type, error, reward) => {
...
if (!rewardedAd.loaded) rewardedAd.load()
})

CasperJS: exit not working

Trying to open random pages through casperJS start method but some pages are loading properly and some of them are not, so in this scenario it is not exiting from casperjs.
It is getting stuck in console then need to manually exit from console using CTR+C.
casper.start("some url", function() {
if(this.status().currentHTTPStatus == 200) {
casper.echo("page is loading");
} else {
casper.echo("page is in error ");
this.exit();
}
});
Wrap it by a then step with a global stepTimeout option.
Sample code:
var casper = require('casper').create({
stepTimeout: 10000 //10s
})
casper.start()
casper.then(funtion(){
casper.open(url)
})
casper.run()
Try bypass() to ignore the next thens.
casper.start("some url", function() {
if(this.status().currentHTTPStatus == 200) {
casper.echo("page is loading");
} else {
casper.echo("page is in error ");
this.bypass(2); // Will not execute the then functions.
}
}).then(function() {
// The 1st then function.
}).then(function() {
// The 2nd then function.
})
casper.run(function() {
this.echo('Something');
this.exit(); // <--- Here.
});

I would like to prevent removing a jquery ui tab

As said in the title I would like to prevent removing a jquery ui tab or at least asking a confirmation before.
I tried
$( "#tabs" ).bind( "tabsremove", function(event, ui) {
var ok=confirm("Are you sure you want to close this tab ?");
if (ok) {
return true;
} else {
return false;
};
});
or
$( "#tabs" ).bind( "tabsremove", function(event, ui) {
var ok=confirm("Are you sure you want to close this tab ?");
if (ok) {
return true;
} else {
return false;
};
});
But the question is asked after, and not before as I want.
Is this possible ?
Is this what you mean?
$( "#tabs span.ui-icon-close" ).live( "click", function() {
var ok=confirm("Are you sure you want to close this tab ?");
if (ok) {
var index = $( "li", $tabs ).index( $( this ).parent() );
$tabs.tabs( "remove", index );
} else {
return false;
};
This is from jQuery-ui-tabs