Skip to content

canShowFirstTime=false stamps shown time = now, starting the interval clock without an ad shown #22

Open

Description

@2sem

Problem

In GADManager.canShow(_:), when canShowFirstTime == false and the delegate's last shown time is <= 1970, the first-time skip calls updatShownTimeForUnit(showTime: now).

That records "skipped" as "shown now", so the unit's interval clock starts although no ad was shown. The first real ad is then blocked until interval elapses.

Repro (relatedstocks app, interstitial interval 30m)

  1. Fresh install, launch → stock → detail → back: skipped (expected).
  2. Relaunch within 30m → stock → detail → back: no ad (expected: ad shows).

Proposed fix

Stamp Date(timeIntervalSince1970: 1) instead of now:

  • the stored value becomes > 1970, so the first-time guard passes on later checks;
  • spent is huge, so it is > interval and the next check can show an ad.

Caveat: with only that change, later canShow calls in the same launch return true too, so the skip covers just the first check, not the whole first launch. To block the full first launch, also keep an in-memory per-unit flag (e.g. skippedFirstTime: Set<E>) that makes canShow return false for the rest of this process.

Workaround in app

2sem/relatedstocks-app-ios#161 blocks the first launch in the app via the delegate and sets canShowFirstTime = true.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions