Search Unity

Native IAP Promo With Monetization SDK 3.0

Discussion in 'Unity Ads & User Acquisition' started by MaulikKaloliya, Jan 20, 2019.

  1. MaulikKaloliya

    MaulikKaloliya

    Joined:
    Sep 28, 2012
    Posts:
    12
    I wanted to integrate Native IAP Promo with Monetization SDK.
    I have done all setup according to this
    https://unityads.unity3d.com/help/monetization/placements

    But i getting issue while creating Unity Promo Adapter of type PromoAdPlacementContent
    https://unityads.unity3d.com/help/beta/native-promo

    I have created "iappromoplacement" for iap promo
    and also started one Promotions with one iap product

    Below is the code that how i am initializing Monetization, basically first i init Unity IAP then after i init Monetization

    i am getting error
    PromoAdPlacementContent promoContent = Monetization.GetPlacementContent("iappromoplacement") as PromoAdPlacementContent;
    INativePromoAdapter adapter = Monetization.CreateNativePromoAdapter (promoContent);

    I also checked that placement is ready or not with
    Monetization.IsReady("iappromoplacement") but it always return false.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Monetization;
    5.  
    6. public class UnityAdsManager : MonoBehaviour
    7. {
    8.     public UnityIAPManager iapManager;
    9.     public UnityIAPAdapter iapAdapter;
    10.    
    11.     string gameId = "1234";
    12.     bool testMode = false;
    13.    
    14.     // Use this for initialization
    15.     void Start ()
    16.     {
    17.         StartCoroutine(InitAds());
    18.     }
    19.    
    20.     public void ShowVideoAd () {
    21.         StartCoroutine (ShowVideoAdWhenReady ());
    22.     }
    23.    
    24.     public void ShowRewardedVideoAd () {
    25.         StartCoroutine (ShowRewardedVideoAdWhenReady ());
    26.     }
    27.  
    28.     public void InitPromoPlacements()
    29.     {
    30.         StartCoroutine(InitPromoPlacementsWhenReady());
    31.     }
    32.  
    33.     private IEnumerator InitAds()
    34.     {
    35.         while (!iapManager.isInit) {
    36.             yield return new WaitForSeconds(0.25f);
    37.         }
    38.         Monetization.SetPurchasingAdapter(iapAdapter);
    39.         Monetization.Initialize (gameId, testMode);
    40.     }
    41.  
    42.     private IEnumerator InitPromoPlacementsWhenReady()
    43.     {
    44.        yield return null;
    45.  
    46.         PromoAdPlacementContent promoContent = Monetization.GetPlacementContent ("iappromoplacement") as PromoAdPlacementContent;
    47.         INativePromoAdapter adapter = Monetization.CreateNativePromoAdapter (promoContent);
    48.         Debug.Log("Promo Placement : " + promoContent + " : " + (promoContent == null));
    49.     }
    50.  
    51.     private IEnumerator ShowVideoAdWhenReady()
    52.     {
    53.         while (!Monetization.IsReady ("video")) {
    54.             yield return new WaitForSeconds(0.25f);
    55.         }
    56.  
    57.         ShowAdPlacementContent ad = null;
    58.         ad = Monetization.GetPlacementContent ("video") as ShowAdPlacementContent;
    59.         Debug.Log("Promo Placement Ready : " + ad);
    60.         if(ad != null) {
    61.             ad.Show ();
    62.         }
    63.     }
    64.  
    65.     private IEnumerator ShowRewardedVideoAdWhenReady()
    66.     {
    67.         while (!Monetization.IsReady ("rewardedVideo")) {
    68.             yield return null;
    69.         }
    70.  
    71.         ShowAdPlacementContent ad = null;
    72.         ad = Monetization.GetPlacementContent ("rewardedVideo") as ShowAdPlacementContent;
    73.  
    74.         Debug.Log("Promo Placement Ready : " + ad);
    75.         if (ad != null) {
    76.             ad.Show (AdFinished);
    77.         }
    78.     }
    79.    
    80.     void AdFinished (ShowResult result) {
    81.         if (result == ShowResult.Finished) {
    82.             // Reward the player
    83.             Debug.Log("Rewarded Video Ad Finished");
    84.         }
    85.     }
    86. }
    87.  
     
  2. alialharbi

    alialharbi

    Joined:
    May 4, 2014
    Posts:
    2
    i faced this issue too i think Native IAP Promo with Monetization still unstable
     
  3. RossRothenstineU3D

    RossRothenstineU3D

    Unity Technologies

    Joined:
    Oct 26, 2018
    Posts:
    4
    Hello there!

    When using UnityPurchasing with UnityMonetization, you don't need to specify a PurchasingAdapter, as we interface directly with UnityPurchasing when available. So
    Monetization.SetPurchasingAdapter(iapAdapter);
    can be removed.

    My guess as to why the IsReady check for that placement returning false is due to the product ID on the dashboard not existing in the product catalog returned from UnityPurchasing. I would double check that the products exist, and then let me know if you're still having an issue.