Skip to content

Ads not hidden when opening a post via widget, push, deeplink, or shortcut #316

Description

@cassio-rossi

Problem

When a post is opened through the app's normal in-app navigation (tapping a news card), the WebView correctly hides ads for users who purchased ad removal. But when the same post is opened via widget, push notification, deeplink (onOpenURL), or Home Screen shortcut, ads are still shown even for purchasing users.

Root cause

Ad removal is driven by the patr cookie, set by MMWebView from @Environment(\.removeAds) (MMWebView.swift:7, 182-187).

\.removeAds is injected only on the MainView subtreeMacMagazineApp.swift:134. Its default value is false (EnvironmentValuesExtensions.swift:26).

All four external entry points set viewModel.deepLinkPostURL, which is presented by a single .fullScreenCover attached at the SceneView.body level (MacMagazineApp.swift:55-66) — a sibling of MainView, not a descendant. So DeepLinkNewsDetailViewMMWebView reads the default false and the patr cookie is written as "false", showing ads.

(\.theme is injected at the body level, which is why the deeplink article is themed correctly but ads are not hidden.)

Fix

Re-inject \.removeAds on the fullScreenCover content, alongside the modelContainer and analytics dependencies already re-injected there (MacMagazineApp.swift:63-64). A single line fixes all four entry points, since they share one presentation.

Affected paths (all share the same cover)

  • Widget / deeplink — onOpenURL (MacMagazineApp.swift:48)
  • Push — newContentAvailable + cold-launch .task (MacMagazineApp.swift:76,104)
  • Shortcut — shortcutManager.url (MacMagazineApp.swift:85)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions