// 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);
    }
 public void OpenFlow(TrialpayEvent tpEvent, string flowId)
 {
     Console.WriteLine("OpenFlow " + tpEvent.GetName() + " flow " + flowId);
 }
 public void EventIsUnavailable(TrialpayEvent tpEvent)
 {
     Console.WriteLine("EventIsUnavailable " + tpEvent.GetName());
 }
 // print announcements
 public void DidOpenEvent(TrialpayEvent tpEvent)
 {
     Console.WriteLine("DidOpenEvent " + tpEvent.GetName());
 }
Esempio n. 5
0
 // Offer Wall/Offer Gallery Event listener
 // Enables/Disables button according to availability
 public void OnStatusChange(TrialpayEvent tpEvent, TPEventStatus status)
 {
     Console.WriteLine("OnStatusChange "+tpEvent.GetName() + " status is " + status);
     if (tpEvent.GetName() == "OfferWall") {
         offerWallBt.enabled = (status == TPEventStatus.TP_Event_Status_Has_Offers);
     } else {
         offerGalleryBt.enabled = (status == TPEventStatus.TP_Event_Status_Has_Offers);
     }
 }
Esempio n. 6
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. 7
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. 8
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);
    }
 public void OnStatusChange(TrialpayEvent tpEvent, TPEventStatus status)
 {
     // got a status change from Trialpay, lest mark to refresh the UI on main thread
     shouldUpdateUI = true;
     lastStatus = status;
 }