يمكنك تحقيق الأرباح من لعبتك من خلال عرض الإعلانات على اللاعبين. يوجد حاليًا تنسيقان لإعلانات Audience Network المدمجة في الألعاب الفورية: مقاطع فيديو بمكافأة والإعلانات الخلالية. سيرشدك هذا القسم خلال عملية دمج تحقيق الأرباح من الإعلانات مع لعبتك الفورية.
منصة | الإعلان الخلالي | إعلان خلالي بمكافأة | إعلان الفيديو بمكافأة |
---|---|---|---|
Android | ✅ | ✅ | ✅ |
iOS | ✅ | ✅ | ✅ |
ويب الهواتف المحمولة | ✅ | ✅ | ✅ |
ويب الكمبيوتر | ✅ | ✅ | ✅ |
ملاحظة: يتم حاليًا تقييد توفير Audience Network في مناطق معينة. تحقق من أهليتك لإجراء دفق إعداد Audience Network.
راجع الدليل 5 خطوات لتحقيق الأرباح من الألعاب الفورية في Audience Network لمزيد من المعلومات.
تكوين تطبيق على فيسبوكإذا قمت بالفعل بتكوين تطبيقك باستخدام مدير الأرباح وأنشأت مواضع الإعلانات الخاصة بك، يمكنك عرض نموذج الرمز البرمجي أدناه أثناء الإجراء من خلال تنزيل العرض التوضيحي المتوفر لدينا:
تنزيل العرض التوضيحي للإعلانات (بتنسيق .zip)الإعلان الخلالي عبارة عن إعلان بملء الشاشة يظهر خلال نقطة انتقال طبيعية داخل تطبيقك. تتوفر الإعلانات الخلالية بتنسيقي التشغيل التلقائي أو النقر للتشغيل. وستبدأ إعلانات التشغيل التلقائي بالعمل بمجرد تحميل الإعلانات الخلالية بحيث يمكن تخطيها بعد 3 ثوان افتراضيًا. أقصى مدة لعرض هذا النوع من الإعلانات هي دقيقتان.
يعرض جزء الرمز البرمجي أدناه مثالاً حول كيفية عرض إعلان خلالي.
حتى يعمل هذا الرمز، يجب أولاً إنشاء موضع إعلان بتنسيق عرض الإعلان الخلالي. كما يجب استخدام موضع مختلف لكل وحدة إعلانية في تطبيقك.
var preloadedInterstitial = null; FBInstant.getInterstitialAdAsync( '123123123123_123123123123' // Your Ad Placement Id ).then(function(interstitial) { // Load the Ad asynchronously preloadedInterstitial = interstitial; return preloadedInterstitial.loadAsync(); }).then(function() { console.log('Interstitial preloaded'); }).catch(function(err){ console.error('Interstitial failed to preload: ' + err.message); });
preloadedInterstitial.showAsync() .then(function() { // Perform post-ad success operation console.log('Interstitial ad finished successfully'); }) .catch(function(e) { console.error(e.message); });
الإعلان الخلالي بمكافأة هو إعلان بملء الشاشة يمنح حافزًا للمستخدم مقابل مشاهدة الإعلان. ولا تتطلب هذه الإعلانات من المستخدم الاشتراك.
يعرض جزء الرمز البرمجي أدناه مثالاً حول كيفية عرض إعلان خلالي بمكافأة.
حتى يعمل هذا الرمز، يجب أولاً إنشاء موضع إعلان بتنسيق عرض إعلان خلالي بمكافأة. تتوفر الإعلانات الخلالية بمكافأة لتطبيقات ألعاب Facebook Gaming وويب الهواتف المحمولة وويب أجهزة الكمبيوتر. كما يجب استخدام موضع مختلف لكل وحدة إعلانية في تطبيقك.
var preloadedRewardedInterstitial = null; FBInstant.getRewardedInterstitialAsync( '123123123123_123123123123' // Your Ad Placement Id ).then(function(rewarded) { // Load the Ad asynchronously preloadedRewardedInterstitial = rewarded; return preloadedRewardedInterstitial.loadAsync(); }).then(function() { console.log('Rewarded interstitial preloaded'); }).catch(function(err){ console.error('Rewarded interstitial failed to preload: ' + err.message); });
preloadedRewardedInterstitial.showAsync() .then(function() { // Perform post-ad success operation console.log('Rewarded interstitial watched successfully'); }) .catch(function(e) { console.error(e.message); });
إعلانات الفيديو بمكافأة عبارة عن تجربة بوضع ملء الشاشة تتيح للمستخدمين اختيار مشاهدة فيديو مقابل الحصول على شيء ما، مثل عملة افتراضية أو عناصر داخل التطبيق أو محتوى حصري.
يعرض جزء الرمز البرمجي أدناه مثالاً حول كيفية عرض إعلان فيديو بمكافأة.
حتى يعمل هذا الرمز، يجب أولاً إنشاء موضع إعلان بتنسيق عرض فيديو بمكافأة. كما يجب استخدام موضع مختلف لكل وحدة إعلانية في تطبيقك.
var preloadedRewardedVideo = null; FBInstant.getRewardedVideoAsync( '456456456456_456456456456' // Your Ad Placement Id ).then(function(rewarded) { // Load the Ad asynchronously preloadedRewardedVideo = rewarded; return preloadedRewardedVideo.loadAsync(); }).then(function() { console.log('Rewarded video preloaded'); }).catch(function(err){ console.error('Rewarded video failed to preload: ' + err.message); });
preloadedRewardedVideo.showAsync() .then(function() { // Perform post-ad success operation console.log('Rewarded video watched successfully'); }) .catch(function(e) { console.error(e.message); });
سيؤدي التحميل المسبق لثلاث مثيلات إعلان من النوع نفسه دون عرضها إلى الإخفاق عند محاولة إنشاء إعلان جديد. وبمجرد تحميل أي إعلان بنجاح، سيصبح الإعلان صالحًا لمدة 60 دقيقة.
إليك عينة من الرمز لمساعدتك في فهم كيفية عمل الأمر، وذلك بافتراض أن كل شيء قد تم تكوينه بشكل صحيح (معرفات موضع إعلان صالحة، وما إلى ذلك) ولا توجد مشكلة في الشبكة:
var preloadedInterstitial1 = null; var preloadedInterstitial2 = null; var preloadedInterstitial3 = null; var preloadedRewardedVideo = null; // PRELOAD PHASE FBInstant.getInterstitialAdAsync( '123123123123_123123123123' ).then(function(interstitial) { // This should get called, meaning you now have 1 ad instance. preloadedInterstitial1 = interstitial; return preloadedInterstitial1.loadAsync(); }).then(function() { // This should get called unless we do not have ads to serve. console.log('Interstitial 1 preloaded') }).catch(function(err){ // This would be called only if we do not have ads to serve. // The error would then be ADS_NO_FILL. // You can try to reload the ad after some time (ideally over 30 seconds). // If you get ADS_NO_FILL 3 times in a row, the instance will be disabled. console.error('Interstitial 1 failed to preload: ' + err.message); // You can try to reload after 30 seconds (2nd attempt) setTimeout(function () { handleAdsNoFill(preloadedInterstitial1, 2); }, 30 * 1000); }); // Here is how the function to handle ADS_NO_FILL would look like function handleAdsNoFill (adInstance, attemptNumber) { if (attemptNumber > 3) { // You can assume we will not have to serve in the current session, no need to try // to load another ad. return; } else { adInstance.loadAsync().then(function() { // This should get called if we finally have ads to serve. console.log('Interstitial preloaded') }).catch(function(err){ console.error('Interstitial failed to preload: ' + err.message); // You can try to reload after 30 seconds setTimeout(function () { handleAdsNoFill(adInstance, attemptNumber+1); }, 30 * 1000); }); } } // As we covered ADS_NO_FILL, from now on let's assume we have ads to serve. FBInstant.getInterstitialAdAsync( // You can re-use the same Ad Placement Id as long as it is of the valid type: // interstitial or rewarded video (here, it has to be interstitial) '123123123123_123123123123' ).then(function(interstitial) { // This should get called, meaning you now have 2 ad instances. preloadedInterstitial2 = interstitial; return preloadedInterstitial2.loadAsync(); }).then(function() { console.log('Interstitial 2 preloaded') }); FBInstant.getRewardedVideoAsync( '456456456456_456456456456' ).then(function(rewarded) { // This should get called, meaning you now have 3 ad instances. preloadedRewardedVideo = rewarded; return preloadedRewardedVideo.loadAsync(); }).then(function() { console.log('Rewarded video preloaded') }); FBInstant.getInterstitialAdAsync( '123123123123_123123123123' ).catch(function(err){ // This should be called now because you already have 3 ad instances. // The error would then be ADS_TOO_MANY_INSTANCES. console.error('Interstitial 3 failed to preload: ' + err.message); }); // SHOWING ADS (at a timing that makes sense in the workflow of your game) preloadedInterstitial1.showAsync() .then(function() { // This should get called, meaning you now have 2 ad instances. console.log('Interstitial ad 1 finished successfully'); }); // A bit later, assuming you did not preload a new instance yet. preloadedInterstitial2.showAsync() .then(function() { // This should get called, meaning you now have 1 ad instance. console.log('Interstitial ad finished successfully'); }); // A bit later, assuming you did not preload a new instance yet. preloadedRewardedVideo.showAsync() .then(function() { // This should get called, meaning you now have no ad instance. console.log('Rewarded video watched successfully'); });
تقتصر المعلومات أدناه على الألعاب الفورية. يُرجى أيضًا الرجوع إلى رؤى Audience Network.
اضبط توقيت الإعلانات بشكل صحيح. تأكد من أن الإعلانات في لعبتك لا تعرقل تجربة اللاعب.
قم بالتحميل المسبق للإعلانات. لا تنتظر حتى آخر دقيقة لطلب الإعلان وتحميله مسبقًا وعرضه في الوقت نفسه. وبدلاً من ذلك، تأكد من أنك قمت بتحميل بعض AdInstances مسبقًا لذا عندما يطلب اللاعب عرضه، فإنه لن ينتظر وقتًا طويلاً.
تحقق من الدعم. في بعض الحالات، لن تدعم جلسة مشغل الفيديو الإعلانات (على سبيل المثال، إذا كان يتم تشغيلها في متصفح على كمبيوتر). يجب التحقق دائمًا مما إذا كانت الإعلانات مدعومة من خلال FBInstant.getSupportedAPIs()
قبل محاولة طلب الإعلان.
قم بتنفيذ المعالجة الصحيحة للإعلانات "بدون عمليات تعبئة". قد تؤدي بعض الحالات إلى عدم تعبئة الإعلان. في تلك الحالة، سيتم رفض الطلب وإرجاع رسالة خطأ ADS_NO_FILL
. تأكد من أن لعبتك تتعامل مع هذا الإعلان بشكل سليم، واعرض رسالة ترحيبية، وانتظر 30 ثانية قبل أن تطلب إعلانًا آخر من النوع نفسه.
اختبر إعلاناتك قبل الإرسال. بصفتك مطوّرًا للتطبيق، يمكنك طلب إعلانات على الهاتف المحمول والتأكد من عملية الدمج تعمل، حتى قبل إرسال تطبيقك لمراجعة Audience Network.
تتبع مرات ظهور الإعلان. يمكنك استخدام الأحداث المخصصة لتتبع مرات ظهور الإعلان عند تحليل showAsync
.
لا تستخدم الكثير من مثيلات AdInstances. كلا الطريقتين getRewardedVideoAsync
أو getInterstitialAdAsync
ترجعان مثيلات AdInstance
التي يمكن تحميلها مسبقًا. وسيؤدي تحميل ثلاثة مثيلات أو أكثر من AdInstances مسبقًا من النوع ذاته دون عرضها إلى فشل المحاولات اللاحقة لإنشاء مثيل AdInstance جديد. وهذا يعني أن عمليات الاستدعاء getRewardedVideoAsync
وgetInterstitialAdAsync
ستفشل وترجع رمز الخطأ ADS_TOO_MANY_INSTANCES
حتى يتم استدعاء showAsync
أو حتى يعيد اللاعب تشغيل Messenger.