Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

MaaS Advertising iOS SDK

Version 4.0.4


This is Phunware's iOS SDK for the MaaS Advertising module. Visit for more details and to sign up.


  • iOS 10.1 or greater
  • Xcode 8.1 or greater
  • Swift 4.1 or 4.2



Phunware recommends using CocoaPods to integrate the framework. To integrate PWAds into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'PWAds'



Banners will be displayed immediately once they are returned from Phunware’s ad server.

The response functions are included in a closure passed to the placement request.

Creating a banner

  • PWBanner(placement, parentViewController, position)
    • placement (currently, only one placement should be returned from Phunware, but in the future a list may be returned. For now, only placement[0] will ever be used.
    • parentViewController (This is the containing controller that should house the banner. Typically this will be the view controller doing the banner request)
    • position (A string constant noting where the banner should appear on screen. Positions values can be found in Phunware.MRAIDConstants)

Retrieving a banner

Width and height are optional here. Most of the time the width and height will come from the zone in your Phunware configuration but if that is not set, you may want to set a fallback here.

let config = PlacementRequestConfig(accountId: <accountId>, zoneId: <zoneId>, width:320, height:50, customExtras:nil)
Phunware.requestPlacement(with: config) { response in
    switch response {
    case .success(_ , let placements):
        guard placements.count == 1 else {
            // error
        guard placements[0].isValid else {
            // error
        self.banner = PWBanner(placement:placements[0], parentViewController:self, position:Positions.BOTTOM_CENTER)
    case .badRequest(let statusCode, let responseBody):
    case .invalidJson(let responseBody):
    case .requestError(let error):


Your view controller will need to implement the PWInterstitialDelegate interface to retrieve event information.

These methods are:

func interstitialReady(_ interstitial: PWInterstitial) {

func interstitialFailedToLoad(_ interstitial: PWInterstitial) {

func interstitialClosed(_ interstitial: PWInterstitial) {

func interstitialStartLoad(_ interstitial: PWInterstitial) {
    print("start load");

Retrieving an interstitial

let config = PlacementRequestConfig(accountId: <accountId>, zoneId: <zoneId>, width:nil, height:nil, customExtras:nil)
Phunware.requestPlacement(with: config) { response in
    switch response {
    case .success(_ , let placements):
        guard placements.count == 1 else {
            return  // interstitials should currently only return a single ad
        guard placements[0].isValid else {
        if(placements[0].body != nil && placements[0].body != ""){
            self.interstitial = PWInterstitial(placement:placements[0], parentViewController:self, delegate:self, respectSafeAreaLayoutGuide:true)

Creating an Interstitial

  • PWInterstitial(placement, parentViewController, delegate, respectSafeAreaLayoutGuide)
    • placement (as with banners, currently only one placement will be returned from Phunware)
    • parentViewController (The view controller which will contain the interstitial, typically the same controller that retrieves the interstitial placement)
    • delegate (A class that implements the PWInterstitialDelegate interface. Typically the view controller which retrieves the interstitial)
    • respectSafeAreaLayoutGuide (Some apps may choose to have their layout take into account the safe area layout guide in order to have the status bar showing. If your app does this, then this setting will tell the interstitial to do the same)

Once retrieved, the interstitialReady function will be called. After this point you can display the interstitial at any time with:


The interstitial can only been displayed once, after which you must retrieve another one.


To use the included Sample, navigate to the Samples/Sample directory in Terminal and execute a pod update command. Once the installation is complete, open Sample.xcworkspace in Xcode.


You understand and consent to Phunware’s Privacy Policy located at If your use of Phunware’s software requires a Privacy Policy of your own, you also agree to include the terms of Phunware’s Privacy Policy in your Privacy Policy to your end users.


Use of this software requires review and acceptance of our terms and conditions for developer use located at