Code Monkey home page Code Monkey logo

billboard's Introduction

Header Photo@2x

Billboard

Billboard is a module that enables the incorporation of advertisement highlights for applications created by independent developers. Its unique feature lies in its execution of ads without the use of tracking measures or unwanted cookies. This way, your user can still get annoyed by advertisements without the nasty bits, and therefore you get a free "Remove Ads" selling point for your premium tier.

These ads do NOT generate revenue or track anything

In Short:

  • 🚫 No tracking/cookies
  • πŸ“² Customizable Ad overlay in SwiftUI
  • πŸ”§ Flexible configuration
  • 🎨 Use the default list of high-quality Ads or use your own source
  • 🌈 Various Ad types
  • 🎁 Ideal to get an ad-free premium tier.

Installation

Ready to use on iOS 15+.

  1. In Xcode, select Add Packages… from the File menu.
  2. Enter https://github.com/hiddevdploeg/Billboard in the search field.
  3. Click Add Package (Set the Dependency Rule to Up to Next Major Version)
  4. After adding the package, you will be able to import Billboard in your project by using.
import Billboard

How to display an Ad

Billboard provides an easy way to present an ad overlay on any SwiftUI View. Here's a simple example:

@State private var showRandomAdvert = false

ContentView()
    .showBillboard(when: $showRandomAdvert) {
        // Replace this view with your Paywall
        Text("Your Paywall goes here")
    }

Alternatively, you can customize the BillboardView and position it in any way that suits your app. This view takes a BillboardAd, a BillboardConfiguration (Optionally), and a view that represents your paywall:

@State private var advertisement: BillboardAd? = nil
@StateObject var viewModel = BillboardViewModel()


ContentView()
    .task {
        let newAdvert = try? await viewModel.fetchRandomAd()
        advertisement = newAdvert
    }   
    .fullScreenCover(item: $advertisement) { advert in
        BillboardView(advert: advert, paywall: { Text("Paywall") })
    }

TIP: When you're running a debug version of your app you can tap on the timer to show a dismiss button right away. Examples@2x

BillboardBannerView

If you don't fancy a fullscreen view but prefer a smaller banner to display within your content you can do that now too! Simple add a BillboardBannerView wherever you like.

@State private var advert: BillboardAd? = nil
ContentView()
    .safeAreaInset(edge: .bottom) {
        if let advert {
            BillboardBannerView(advert: advert)
                .padding()
        }
    }

By default it comes with a shadow, which you can opt-out from by changing the includeShadow value. Here's an example on how you could include a BillboardBannerView in your list:

@State private var advert: BillboardAd? = nil

List {
    if let advert {
        Section {
            BillboardBannerView(advert: advert, includeShadow: false)
                .listRowBackground(Color.clear)
                .listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0))
        }
    }
    
    // Rest of the list...
}

You can also hide the dismiss button to have a persistent banner, by adding hideDismissButtonAndTimer: true to your BillboardBannerView.

BillboardBannerExamples

Configuration

Billboard lets you define some configurations to fit your needs better.

public struct BillboardConfiguration {
    
    /// The URL pointing to the JSON in the `BillboardAdResponse` format.
    public let adsJSONURL: URL?
    
    /// Enable or disable haptics
    public let allowHaptics: Bool
    
    /// The duration of the advertisement
    public let duration: TimeInterval
    
    /// Provide a list of Apple ID's that you want to exclude from showing up (e.g. your own app)
    public let excludedIDs : [String]
    
    public init(adsJSONURL: URL? = URL(string:"https://billboard-source.vercel.app/ads.json"),
                allowHaptics: Bool = true,
                advertDuration: TimeInterval = 15.0, excludedIDs: [String] = []) {
        self.adsJSONURL = adsJSONURL
        self.allowHaptics = allowHaptics
        self.duration = advertDuration
        self.excludedIDs = excludedIDs
    }
}

This also allows you to use your own source of ads that follow the BillboardAdResponse format.

@State private var showRandomAdvert = false

let config = BillboardConfiguration(
    adsJSONURL: URL(string: "YOUR-OWN-SOURCE"),
    allowHaptics: false,
    advertDuration: 30.0,
    excludedIDs: ["1234567890"]
)

ContentView()
    .showBillboard(when: $showRandomAdvert, configuration: config) {
        // Replace this view with your Paywall
        Text("Your Paywall goes here")
    }

BillboardAdResponse

Here's an example of how your source list could look like.

{
  "ads" : [
    {
      "appStoreID" : "1574243765",
      "name" : "NowPlaying",
      "title": "Learn everything about any song",
      "description" : "A music companion app that lets you discover the stories behind and song, album or artist.",
      "media": "https://pub-378e0dd96b5343108a04317ebddebb4e.r2.dev/nowplaying.png",
      "backgroundColor" : "344442",
      "textColor" : "EFDED7",
      "tintColor" : "EFDED7",
      "fullscreen": false,
      "transparent": true
    }
  ]
}

Ad Example@2x

Ad Guidelines & Requirements

Submit your app to be featured as an Ad for everyone using the Billboard package to display Advertisements. Each ad will be reviewed before inclusion.

You can submit your app here

Feel free to use the Billboard template for Figma to tweak and preview the promo.

Ad Requirements

  • Apple ID of App: The Apple ID is a 9- or 10-digit number found in your App Store URL or in App Store Connect.
  • Name of App: The name of the app you're promoting
  • Title: The advertisement headline (maximum 25 characters).
  • Description: The advertisement description (maximum 140 characters).
  • Media: The image used in your advertisement.

Media Guidelines

  • Image should be a minimum of 1280x1280 in resolution.
  • The image should not contain any text outside of the visual content.
  • Avoid using your App Icon as the image (as it's already displayed by default).
  • Provide an image with no background or has a single color (avoid gradients).
  • Photos are allowed as well but will be displayed differently.
  • Try and submit an evergreen image that represents your app, show it's good practice to avoid showing UI that gets outdated fast.

Ad Types

The media of an ad will be displayed covering the whole view when BillboardAd.fullscreen is set to true. This works great if the media is a photo instead of a visual. Please consider that the photo's subject must be in the center, which will ensure it's always visible.

AdTypes@2x

FAQ

Which Ads are presented when I use the default config

You'll find a list of all currently used ads in the example app.

Special thanks to

tundsdev for CachedImage implementation

Authors

This library is created by Hidde van der Ploeg. Feel free to reach out on Twitter or Mastodon.

License

Billboard is available under the MIT license.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

billboard's People

Contributors

appfrosch avatar dhaydl avatar ekurutepe avatar hiddevdploeg avatar jjrscott avatar omit2c avatar polpielladev avatar tkafka avatar witekbobrowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

billboard's Issues

visionOS support?

Great work on the package. I was wondering if visionOS support would be possible, as I think it should be as easy as disabling all haptic feedback (as that isn't available on visionOS). TIA!

Fetching one or more adverts currently not possible as described in the documentation

based on the current documentation, it should be possible to fetch an ad via BillboardViewModel like this:

let newAdvert = try? await viewModel.fetchRandomAd()
advertisement = newAdvert

but there are two difference to what is actually implemented in code:

  • fetchRandomAd needs an URL parameter
  • fetchRandomAd is static

current workaround:

guard  let adsURL = BillboardConfiguration().adsJSONURL else {
    return
}

Task {
    try await BillboardViewModel.fetchRandomAd(from: adsURL)
}

a good solution would be to merge showAdvertisement and fetchRandomAd somehow. what would you say to this?

Project doesn't build

Hi. The demo app project doesn't compile. It seems BillboardBannerView isn't present in the package on the main branch

Rendered ads have a off-by-one image/content association

Hi, I noticed that the images associated to a banner have the tendency to fall behind after the 1st rendering.

The first ad works well, then there is a tab switch and coming back to the previous page starts having the mentioned issue.
Example:

Screenshot 2024-04-20 at 12 26 26 Screenshot 2024-04-20 at 12 26 52 Screenshot 2024-04-20 at 12 27 28

The difference between displayed ad and image never increases more than 1 from my tests.
Tapping on them loads the advert for the title/subtitle displayed.

Allow for providerToken and campaignToken

providerToken (from the app) and the a campaignToken, people can attribute the installs in ASC

let config = SKOverlay.AppConfiguration(appIdentifier: advert.appStoreID, position: .bottom)
config.userDismissible = true
config.campaignToken = "CAMPAIGN_TOKEN"
config.providerToken = "PROVIDER_ID"

Add support for Categories

Give the public list categories and let you only show ads from specific categories to better match your own app

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.