'i integrate Tapjoy in react native but the problem is i'm getting this error [Error: Placement content not ready.]
{ const tapjoyOptions = {
sdkKeyIos: 'Q6nee290RvKnSpxjmYOxEQEBcoe5dGB3DvoOUq65NtjVQyjKdJRKLJ3UTxAo',
sdkKeyAndroid: 'Hq7jIdwHQXWCgJnT1H5ZdAECcDubXKblZ1Zpc2EmqiGnr1KDPShKerrWQZuA',
gcmSenderIdAndroid: '389658608176',
debug: true,
};
const Tapjoy1 = () => {
const [
{ tapjoyEvents },
{
initialiseTapjoy,
listenToEvent,
addTapjoyPlacement,
showTapjoyPlacement,
requestTapjoyPlacementContent,
},
] = useTapjoy(tapjoyOptions);
const [connected, setConnected] = useState(false);
const listenForEarnedCurrencyCallback = useCallback(
({ amount, currencyName }) => {
alert(Earned ${amount} ${currencyName});
},
[],
);
useEffect(() => {
const tapjoyEvent = 'onPlacementContentReady';
const listeners = { tapjoyEvent };
tapjoyEvents.forEach(tapjoyEvent => {
listeners[tapjoyEvent] = listenToEvent(tapjoyEvent, evt => {
console.log(evt);
});
});
return () => {
for (const key in listeners) {
if (listeners[key] && listeners[key].remove) {
listeners[key].remove();
}
}
};
}, [listenToEvent, tapjoyEvents]);
useEffect(() => {
const foo = async () => {
try {
const initialized = await initialiseTapjoy();
setConnected(true);
if (initialized) {
const placementAdded = await addTapjoyPlacement('interstitial');
console.log(placementAdded);
{
console.log('placementAdded', placementAdded);
}
if (placementAdded) {
const contentRequested = await requestTapjoyPlacementContent(
'interstitial',
);
console.log(contentRequested);
}
}
} catch (e) {
setConnected(false);
alert(e.message);
}
};
console.log('tapjoyEvents', tapjoyEvents);
foo();
}, []);
return (
{!connected ? (
Tapjoy is not connected.
) : (
Tapjoy is connected
)}
{connected && (
<Button
title="Show Placement"
style={styles.sectionTitle}
onPress={async () => {
try {
await requestTapjoyPlacementContent('interstitial');
} catch (e) {
console.log(e);
}
try {
await showTapjoyPlacement('interstitial');
} catch (e) {
console.log(e);
}
}}
/>
)}
);
};}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
