{"id":23134390,"url":"https://github.com/vmlweb/vlbanner","last_synced_at":"2025-04-04T08:20:42.778Z","repository":{"id":95819290,"uuid":"44050488","full_name":"Vmlweb/VLBanner","owner":"Vmlweb","description":"iAd, AdMob and IAP wrapper for iOS","archived":false,"fork":false,"pushed_at":"2016-04-01T19:50:28.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T19:24:20.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vmlweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-11T12:02:31.000Z","updated_at":"2017-08-18T03:28:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c7655fb-2f02-4326-b8ac-2769da5221bd","html_url":"https://github.com/Vmlweb/VLBanner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vmlweb%2FVLBanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vmlweb%2FVLBanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vmlweb%2FVLBanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vmlweb%2FVLBanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vmlweb","download_url":"https://codeload.github.com/Vmlweb/VLBanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142416,"owners_count":20890723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T12:10:18.468Z","updated_at":"2025-04-04T08:20:42.760Z","avatar_url":"https://github.com/Vmlweb.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VLBanner\niAd, AdMob and IAP wrapper for iOS using Swift.\n\n## Features\n  * iAd and AdMob support\n  * iPhone and iPad compatability\n  * In app purchase to remove advert\n\n## Installation\n\n1) Add these lines to your Podfile.\n```bash\npod 'CryptoSwift'\npod 'Google/AdMob'\n```\n\n2) Add VLBanner.h to the build settings your target under:\n\"Swift Compiler - Code Generation\" -\u003e \"Objective -C Bridging Header\"\n\n3) You may get an error regarding bitcode, disable this under:\n\"Build Options\" -\u003e \"Enable Bitcode\"\n\n## Getting Started\n\n```swift\nlet advert = VLBanner.shared\nadvert.adUnitID = \"ca-app-pub-xxxxxxxx/xxxxxxxx\" //Insert your AdMob identifier here\nadvert.production = false //Choose whether test or production adverts are shown\nadvert.viewController = self //View controller to present modal adverts\nself.view.addSubview(advert)\nadvert.start() //Begin advert cycle\n```\n\nThe banner will resize itself as needed to display its current content.\nConstraints can be used to auto resize superviews and ui elements to fit onto the banner.\n\n## Default View\n\nYou can specify a custom view to be displayed when there are no adverts to present.\n```swift\nlet advert = VLBanner.shared\nadvert.defaultView = UILabel(frame: advert.frame)\nlet defaultLabel = advert.defaultView as! UILabel\ndefaultLabel.text = \"Remove This Advert\"\ndefaultLabel.font = UIFont(name: \"Helvetica Bold\", size: 20)\ndefaultLabel.textAlignment = NSTextAlignment.Center\ndefaultLabel.backgroundColor = UIColor.blackColor()\ndefaultLabel.textColor = UIColor.whiteColor()\n```\nSee below for the delegate method to detect touches to the default view.\n\n## Container View\n\nYou can use the VLBannerContainer view controller subclass to wrap and respond correctly to the interface.\n\n```swift\n//Setup banner container\nlet bannerContainer = VLBannerContainer()\nbannerContainer.subControllers.append(self)\nbannerContainer.addChildViewController(self)\nbannerContainer.edgesForExtendedLayout = UIRectEdge.None\nbannerContainer.view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]\n\n//Get application delegate\nlet appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate\nlet window = appDelegate.window!\n\n//Add and remove views\nself.view.removeFromSuperview()\nbannerContainer.view.addSubview(self.view)\nwindow.rootViewController = bannerContainer\n```\n\n## Background App State\n\nTo manage the app properly in the background use the pause and resume meothds.\n\n```swift\nfunc applicationDidEnterBackground(application: UIApplication) {\n\tVLBanner.shared.pause()\n}\nfunc applicationWillEnterForeground(application: UIApplication) {\n\tVLBanner.shared.resume()\n}\n```\n\n## Advert Delegate\n\nYou can use the protocol `VLBannerPurchaseDelegate` to be notified of advert changes.\n```swift\nlet advert = VLBanner.shared\nadvert.advertDelegate = self\n```\n\nYou then have access to the following methdods.\n```swift\nfunc advertDefaultAction(advert: VLBanner) //Default view was pressed\nfunc advertViewDidLoadAd(advert: VLBanner) //iAd or AdMob was loaded into view\nfunc advertView(advert: VLBanner, didFailToReceiveAdWithError error: NSError) //iAd or AdMob returned an error\nfunc advertViewActionShouldBegin(advert: VLBanner) //Modal advert presented from user click\nfunc advertViewActionDidFinish(advert: VLBanner) //Modal advert finished presenting\n```\n\n## In App Purchasing\n\nYou can use an in app purchase to enable the user to pay for the adverts removal.\n```swift\nlet advert = VLBanner.shared\nadvert.iapIdentifier = \"com.myapp.iap.adverts\" //IAP identifier from iTunes Connect\nadvert.purchaseDelegate = self\n```\n\nOnce the IAP has been setup you can use the following methods to start an IAP transaction.\n```swift\nlet advert = VLBanner.shared\nadvert.purchaseRemoveAdverts()\nadvert.restoreRemoveAdverts()\n```\nIf the transaction has been successful the banner will automaticlly hide itself and store its state in `NSUserDefaults`.\nYou can access this value via the `VLBanner.shared.iapPurchased` boolean property. (true is hidden)\n\nYou can then use the following `VLBannerPurchaseDelegate` methods to be notified of IAP changes.\n```swift\nfunc purchaseIAPSuccessful(advert: VLBanner, transaction: SKPaymentTransaction)\nfunc purchaseIAPRestored(advert: VLBanner, transaction: SKPaymentTransaction)\nfunc purchaseIAPFailed(advert: VLBanner, didFailToPurchaseWithError error: NSError)\n```\n\n## Get IAP Information\n\nYou can request an `SKProduct` object from the banner to obtain IAP information such as price.\n```swift\nlet advert = VLBanner.shared\nadvert.requestProduct { (error, product) -\u003e Void in\n guard let product = product else{ return }\n guard let defaultLabel = advert.defaultView as? UILabel else{ return }\n  \n //Format price to string\n\tlet formatter = NSNumberFormatter()\n\tformatter.numberStyle = .CurrencyStyle\n\tformatter.locale = product.priceLocale\n\tdefaultLabel.text = \"Remove This Advert \\(formatter.stringFromNumber(product.price)!)\"\n}\n```\nYou can use the `VLBanner.shared.userInfo` property to store the `SKProduct` if it is required elsewhere.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmlweb%2Fvlbanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmlweb%2Fvlbanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmlweb%2Fvlbanner/lists"}