// Use this for initialization
    void Awake()
    {
        // Start with no offers and wait for availability response
        lastStatus = TPEventStatus.TP_Event_Status_No_Offers;
        shouldUpdateUI = true;

        // Create event and listen to availability changes
        nativeEvent = TrialpayEvent.CreateEvent("NativeAds");
        nativeEvent.SetOnStatusChangeListener(this);
    }
Esempio n. 2
0
 public void OnStatusChange(TrialpayEvent tpEvent, TPEventStatus status)
 {
     var diff = (DateTime.Now - launched).TotalSeconds;
     if (status == TPEventStatus.TP_Event_Status_Has_Offers) {
         // Dont launch if event takes more than 15sec to become available
         if (diff <= 15) {
             // stop listening so we dont fire again
             tpEvent.SetOnStatusChangeListener(null);
             // Open offer
             tpEvent.Fire();
         }
     }
 }
Esempio n. 3
0
    // Create an OnLaunch event every time we launch the app OR
    // the user was on background for more than 60s to improve UX when user is doing a quick
    // action outside the app.
    void PrepareOnLaunch(string reason)
    {
        // Calculate the amount of time on background
        double diffInSeconds = 0;
        if (backgroundDate != default(DateTime)) {
            diffInSeconds = (DateTime.Now - backgroundDate).TotalSeconds;
        }

        // If just launched or over 60s on background
        if (backgroundDate == default(DateTime) || diffInSeconds >= 60) {
            // Create the OnLaunch event
            onLaunchEvent = TrialpayEvent.CreateEvent("OnLaunch");
            // Open offers when available (if available within 15s)
            onLaunchEvent.SetOnStatusChangeListener(new MyLaunchListener());
        }
    }
Esempio n. 4
0
    void Awake()
    {
        // Initialize Trialpay
        TrialpayListener.InitApp();

        // Create an Offer Wall event
        offerWallEvent = TrialpayEvent.CreateEvent("OfferWall");
        offerWallEvent.SetOnStatusChangeListener(this);

        // Create an Offer Gallery event
        offerGalleryEvent = TrialpayEvent.CreateEvent("OfferGallery");
        offerGalleryEvent.SetOnStatusChangeListener(this);

        // Print the SDK version and user id (demo only)
        versionText.text = "SDK: " + Trialpay.GetSdkVersion() + " App: " + BuildDate.ToString("yyyyMMdd-HHmm");
        sidText.text = "User Id: " + TrialpayListener.GetUserID();

        // Disable buttons until offers are available
        offerWallBt.enabled = false;
        offerGalleryBt.enabled = false;

        Screen.SetResolution(Screen.width, Screen.height, false);
    }