{"_id":"5a210ae78415d200120a93ec","project":"574ff4bd3fa1870e00889ba6","version":{"_id":"574ff4bd3fa1870e00889ba9","project":"574ff4bd3fa1870e00889ba6","__v":24,"createdAt":"2016-06-02T08:56:29.492Z","releaseDate":"2016-06-02T08:56:29.492Z","categories":["574ff4bd3fa1870e00889baa","577278ecdceb570e003a9001","577279865617b117009e643f","577279985617b117009e6440","577279bc8c48e00e00503504","5774fe18605b770e0037be8a","577ce3ad87acf617003c4187","577f8476a77c700e006a6c52","57b486ae0d2b640e00e9d3f5","57b722133d3e620e004ec74b","57bd95f00fe3a00e003e2cc5","57c8349359cd4b0e00b888ef","57c8349b5754fa1700b12242","57cedb0bad483e0e00890239","57cedbe807d7ea0e00e438cc","57d82967156ef72b007ffcd8","58ee353ad1ee2f0f0034a13d","596623221738df00298622a5","59a51730192dba000fc9ca38","59a8129f1e7b26000fa0fb1a","5a0322bf044b6f001c236e36","5a79897c5b6e430030746df6","5a79898c2b2d5f0012cbab63","5ab3b5e3d2d1e2006252a8f2"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.0.0","version":"3.0"},"category":{"_id":"59a8129f1e7b26000fa0fb1a","project":"574ff4bd3fa1870e00889ba6","version":"574ff4bd3fa1870e00889ba9","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-08-31T13:43:59.109Z","from_sync":false,"order":12,"slug":"unity-sdk","title":"Unity SDK"},"user":"5770fa1ce5a0000e0023c680","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-12-01T07:55:19.057Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"PubNative Plugin for Unity supports 2 ad formats:\n\n  * **[Banner](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#banner-integration-instructions)**\n  * **[Interstitial](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#interstitial-integration-instructions)**\n\nPlease follow this integration guide to configure PubNative ads.\n[block:api-header]\n{\n  \"title\": \"Requirements\"\n}\n[/block]\n* Unity Project. - _(This Plugin supports Unity 5 and up)_\n* PubNative iOS SDK. It can be found [here](https://github.com/pubnative/pubnative-ios-sdk/releases/tag/2.0.1)\n* PubNative Unity Plugin. It can be found [here](https://drive.google.com/file/d/1XDDMR6tMDlGhGmn4KWL2qrPfdt0OBOtg/view?usp=sharing)\n* An **App Token** provided in PubNative Dashboard.\n* A **Placement Name** configured and obtained from the PubNative Dashboard\n[block:api-header]\n{\n  \"title\": \"Unity Plugin Integration\"\n}\n[/block]\nYou can download the Unity Plugin from [here](https://drive.google.com/file/d/1XDDMR6tMDlGhGmn4KWL2qrPfdt0OBOtg/view?usp=sharing).\n\n* Open the project in the Unity Editor\n* Make sure that the **Assets** folder is created in the project folder\n* With the project open, Copy and Paste the **Editor**, **Plugins** and **Scripts** folders with all the files inside of them into the **Assets** folder. **(_You can dismiss the “Could not create texture from…” errors that come up in the console._)**\n\nNow the plugin is integrated and ready to begin the specific integration per ad format. You can integrate this plugin into 2 ad formats:\n\n * **[Banner](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#banner-integration-instructions)**\n * **[Interstitial](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#interstitial-integration-instructions)**\n\n# Caution\n\nWhen you export your Unity Project into a Xcode project make sure to include this step below:\n\n  * Select your target and navigate to the **“Build Phases”**. Then, add a **Run Script** step to your build steps. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/dcd8a34-Screen_Shot_2017-12-01_at_10.42.17.png\",\n        \"Screen Shot 2017-12-01 at 10.42.17.png\",\n        604,\n        173,\n        \"#ebebeb\"\n      ]\n    }\n  ]\n}\n[/block]\n  * Put it after your step to embed frameworks, set it to use /bin/sh and enter the following script: \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"APP_PATH=\\\"${TARGET_BUILD_DIR}/${WRAPPER_NAME}\\\"\\n\\nfind \\\"$APP_PATH\\\" -name 'Pubnative.framework' -type d | while read -r FRAMEWORK\\ndo\\n    FRAMEWORK_EXECUTABLE_NAME=$(defaults read \\\"$FRAMEWORK/Info.plist\\\" CFBundleExecutable)\\n    FRAMEWORK_EXECUTABLE_PATH=\\\"$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME\\\"\\n    echo \\\"Executable is $FRAMEWORK_EXECUTABLE_PATH\\\"\\n\\n    EXTRACTED_ARCHS=()\\n\\n    for ARCH in $ARCHS\\n    do\\n        echo \\\"Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME\\\"\\n        lipo -extract \\\"$ARCH\\\" \\\"$FRAMEWORK_EXECUTABLE_PATH\\\" -o \\\"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\\\"\\n        EXTRACTED_ARCHS+=(\\\"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\\\")\\n    done\\n\\n    echo \\\"Merging extracted architectures: ${ARCHS}\\\"\\n    lipo -o \\\"$FRAMEWORK_EXECUTABLE_PATH-merged\\\" -create \\\"${EXTRACTED_ARCHS[:::at:::]}\\\"\\n    rm \\\"${EXTRACTED_ARCHS[@]}\\\"\\n\\n    echo \\\"Replacing original executable with thinned version\\\"\\n    rm \\\"$FRAMEWORK_EXECUTABLE_PATH\\\"\\n    mv \\\"$FRAMEWORK_EXECUTABLE_PATH-merged\\\" \\\"$FRAMEWORK_EXECUTABLE_PATH\\\"\\n\\ndone\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n  * Do not forget to check your project’s *“Frameworks Search Paths”* in your Build Settings. Make sure that the path for **Pubnative.framework** is provided correctly.\n[block:api-header]\n{\n  \"title\": \"Banner integration instructions\"\n}\n[/block]\n# Creating the Banner\n\nThe **PNBanner** should be created inside a script which is linked to a **GameObject**. It must be created using the PNBannerFactory **`createBanner()`** method which created a banner based on the platform that the application is being built for.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public static PNBanner createBanner(MonoBehaviour parent) \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nA sample of this instantiation is the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PNBanner banner = PNBannerFactory.createBanner(this);\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nIn the previous sample **`this`** is an object which inherits from MonoBehaviour so it’s linked to a **GameObject**.\n\nAfter creating the Banner you must set the **appToken** and **placement** properties:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"banner.appToken = “App Token obtained from PubNative dashboard”;\\nbanner.placement = “Placement Name configured and obtained from the PubNative Dashboard”;\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nSetting the listeners is also recommended to check the correct behavior of the ads. There are two listeners for **PNBanner**: **`ILoadListener()`** and **`ITrackListener()`**.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public interface ILoadListener\\n{\\n    void OnLoadFinished();\\n    void OnLoadFailed(Exception error);\\n} \\n\\npublic interface ITrackListener\\n{\\n    void OnImpressionTracked();\\n    void OnClickTracked();\\n} \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nAdding a **LoadListener** to the **PNBanner** is mandatory since it will send callbacks when the ad was loaded or failed. After the ad is loaded then it can be displayed.\n\n**TrackListener** is optional in case you want to receive callbacks when the ad has been impressed on screen or when the ad has been clicked.\n\nHere’s an implementation sample:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"banner.LoadListener = LOAD_LISTENER_INSTANCE;\\nbanner.TrackListener = TRACK_LISTENER_INSTANCE;\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n# Loading the banner\n\nTo load the Banner you should use the **`Load()`** method. This method must be invoked in the following way:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"banner.Load(); \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nThe result of this method will be received in the **LoadListener** callbacks.\n\n# Showing the banner\n\nThe Banner can be displayed in two positions on the screen: TOP or BOTTOM. After the ad is loaded successfully, the **`Show(Position position)`** method must be used to display the ad.\n\nHere’s are samples of how to show the Banner on top or bottom of the screen.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"banner.Show(PNBanner.Position.TOP); \\nbanner.Show(PNBanner.Position.BOTTOM); \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n_**Keep in mind, this method should be called always after receiving confirmation that the ad was loaded successfully. Otherwise, it’ll result in an error and nothing will be displayed.**_\n\n# Code sample\n\nHere is a complete code sample about how you can integrate the Banner.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"using System;\\nusing System.Collections;\\nusing System.Collections.Generic;\\nusing UnityEngine;\\nusing UnityEngine.UI;\\n\\npublic class BannerNative : MonoBehaviour, ILoadListener, ITrackListener\\n{\\n    private PNBanner banner;\\n\\n    public string appToken;\\n    public string placement;\\n\\n    [SerializeField]\\n    private Button _buttonLoadBanner;\\n\\n    [SerializeField]\\n    private Button _buttonHideBanner;\\n\\n    // Use this for initialization\\n    void Start()\\n    {\\n        banner = PNBannerFactory.createBanner(this);\\n        banner.appToken = appToken;\\n        banner.placement = placement;\\n        banner.LoadListener = this;\\n        banner.TrackListener = this;\\n        _buttonLoadBanner.onClick.AddListener(RequestBanner);\\n        _buttonHideBanner.onClick.AddListener(HideBanner);\\n    }\\n\\n    private void RequestBanner()\\n    {\\n        if (banner != null) {\\n            banner.Load();\\n        }\\n    }\\n\\n    private void HideBanner()\\n    {\\n        banner.Hide();\\n    }\\n\\n    public void OnLoadFinished()\\n    {\\n        banner.Show(PNBanner.Position.TOP);\\n    }\\n\\n    public void OnLoadFailed(Exception error)\\n    {\\n        // Handle error\\n    }\\n\\n    public void OnImpressionTracked()\\n    {\\n        // Handle Impression\\n    }\\n\\n    public void OnClickTracked()\\n    {\\n        // Handle Click\\n    }\\n} \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Interstitial integration instructions\"\n}\n[/block]\n# Creating the Interstitial\n\nThe **PNInterstitial** should be created inside a script which is linked to a **GameObject**. It must be created using the PNInterstitialFactory **`createInterstitial()`** method which created an interstitial based on the platform that the application is being built for.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public static PNInterstitial createInterstitial(MonoBehaviour parent) \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nA sample of this instantiation is the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PNInterstitial interstitial = PNInterstitialFactory.createInterstitial(this);  \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nIn the previous sample **`this`** is an object which inherits from MonoBehaviour so it’s linked to a **GameObject**.\n\nAfter creating the Interstitial you must set the **appToken** and **placement** properties:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"interstitial.appToken = “App Token obtained from PubNative dashboard”;\\ninterstitial.placement = “Placement Name configured and obtained from the PubNative Dashboard”;\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nSetting the listeners is also recommended to check the correct behavior of the ads. There are three listeners for **PNInterstitial**: **`ILoadListener()`**, **`ITrackListener()`** and **`IViewListener()`**.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public interface ILoadListener\\n{\\n    void OnLoadFinished();\\n    void OnLoadFailed(Exception error);\\n} \\n\\npublic interface ITrackListener\\n{\\n    void OnImpressionTracked();\\n    void OnClickTracked();\\n} \\n\\npublic interface IViewListener\\n{\\n    void OnShown();\\n    void OnHidden();\\n} \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nAdding a **LoadListener** to the **PNInterstitial** is mandatory since it will send callbacks when the ad was loaded or failed. After the ad is loaded then it can be displayed.\n\n**TrackListener** is optional in case you want to receive callbacks when the ad has been impressed on screen or when the ad has been clicked.\n\n**ViewListener** is optional in case you want to receive callbacks when the Interstitial has been shown and hidden.\n\nHere’s an implementation sample:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"interstitial.LoadListener = LOAD_LISTENER_INSTANCE;\\ninterstitial.TrackListener = TRACK_LISTENER_INSTANCE; \\ninterstitial.ViewListener = VIEW_LISTENER_INSTANCE;\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n\n# Loading the interstitial\n\nTo load the Interstitial you should use the **`Load()`** method. This method must be invoked in the following way:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"interstitial.Load();  \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nThe result of this method will be received in the **LoadListener** callbacks.\n\n# Showing the interstitial\n\nAfter the ad is loaded successfully, the method **`Show()`** must be used to display the ad.\n\nHere’s is the sample of how to show interstitial on screen.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"interstitial.Show(); \",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n_**Keep in mind, this method should be called always after receiving confirmation that the ad was loaded successfully. Otherwise, it’ll result in an error and nothing will be displayed.**_\n\n# Code sample\n\n**Here is a complete code sample about how you can integrate the Interstitial.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"using System;\\nusing System.Collections;\\nusing System.Collections.Generic;\\nusing UnityEngine;\\nusing UnityEngine.UI;\\n\\npublic class InterstitialNative : MonoBehaviour, ILoadListener, ITrackListener, IViewListener\\n{\\n    private PNInterstitial interstitial;\\n\\n    public string appToken;\\n    public string placement;\\n\\n    [SerializeField]\\n    private Button _buttonLoadInterstitial;\\n\\n    // Use this for initialization\\n    void Start()\\n    {\\n        interstitial = PNInterstitialFactory.createInterstitial(this);\\n        interstitial.appToken = appToken;\\n        interstitial.placement = placement;\\n        interstitial.LoadListener = this;\\n        interstitial.TrackListener = this;\\n        interstitial.ViewListener = this;\\n        _buttonLoadInterstitial.onClick.AddListener(RequestInterstitial);\\n    }\\n\\n    private void RequestInterstitial()\\n    {\\n        if (interstitial != null) {\\n            interstitial.Load();\\n        }\\n    }\\n\\n    public void OnLoadFinished()\\n    {\\n        interstitial.Show();\\n    }\\n\\n    public void OnLoadFailed(Exception error)\\n    {\\n        // Handle error\\n    }\\n\\n    public void OnImpressionTracked()\\n    {\\n        // Handle Impression\\n    }\\n\\n    public void OnClickTracked()\\n    {\\n        // Handle Click\\n    }\\n\\n    public void OnShown()\\n    {\\n        // Handle interstitial show\\n    }\\n\\n    public void OnHidden()\\n    {\\n        // Handle interstitial hide\\n    }\\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Demo app\"\n}\n[/block]\nHere is [the demo project](https://drive.google.com/file/d/1XDDMR6tMDlGhGmn4KWL2qrPfdt0OBOtg/view?usp=sharing) for unity and the generated iOS project.","excerpt":"","slug":"ios-plugin-1","type":"basic","title":"iOS Plugin"}
PubNative Plugin for Unity supports 2 ad formats: * **[Banner](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#banner-integration-instructions)** * **[Interstitial](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#interstitial-integration-instructions)** Please follow this integration guide to configure PubNative ads. [block:api-header] { "title": "Requirements" } [/block] * Unity Project. - _(This Plugin supports Unity 5 and up)_ * PubNative iOS SDK. It can be found [here](https://github.com/pubnative/pubnative-ios-sdk/releases/tag/2.0.1) * PubNative Unity Plugin. It can be found [here](https://drive.google.com/file/d/1XDDMR6tMDlGhGmn4KWL2qrPfdt0OBOtg/view?usp=sharing) * An **App Token** provided in PubNative Dashboard. * A **Placement Name** configured and obtained from the PubNative Dashboard [block:api-header] { "title": "Unity Plugin Integration" } [/block] You can download the Unity Plugin from [here](https://drive.google.com/file/d/1XDDMR6tMDlGhGmn4KWL2qrPfdt0OBOtg/view?usp=sharing). * Open the project in the Unity Editor * Make sure that the **Assets** folder is created in the project folder * With the project open, Copy and Paste the **Editor**, **Plugins** and **Scripts** folders with all the files inside of them into the **Assets** folder. **(_You can dismiss the “Could not create texture from…” errors that come up in the console._)** Now the plugin is integrated and ready to begin the specific integration per ad format. You can integrate this plugin into 2 ad formats: * **[Banner](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#banner-integration-instructions)** * **[Interstitial](http://developers.pubnative.net/v3.0/docs/ios-plugin-1#interstitial-integration-instructions)** # Caution When you export your Unity Project into a Xcode project make sure to include this step below: * Select your target and navigate to the **“Build Phases”**. Then, add a **Run Script** step to your build steps. [block:image] { "images": [ { "image": [ "https://files.readme.io/dcd8a34-Screen_Shot_2017-12-01_at_10.42.17.png", "Screen Shot 2017-12-01 at 10.42.17.png", 604, 173, "#ebebeb" ] } ] } [/block] * Put it after your step to embed frameworks, set it to use /bin/sh and enter the following script: [block:code] { "codes": [ { "code": "APP_PATH=\"${TARGET_BUILD_DIR}/${WRAPPER_NAME}\"\n\nfind \"$APP_PATH\" -name 'Pubnative.framework' -type d | while read -r FRAMEWORK\ndo\n FRAMEWORK_EXECUTABLE_NAME=$(defaults read \"$FRAMEWORK/Info.plist\" CFBundleExecutable)\n FRAMEWORK_EXECUTABLE_PATH=\"$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME\"\n echo \"Executable is $FRAMEWORK_EXECUTABLE_PATH\"\n\n EXTRACTED_ARCHS=()\n\n for ARCH in $ARCHS\n do\n echo \"Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME\"\n lipo -extract \"$ARCH\" \"$FRAMEWORK_EXECUTABLE_PATH\" -o \"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\"\n EXTRACTED_ARCHS+=(\"$FRAMEWORK_EXECUTABLE_PATH-$ARCH\")\n done\n\n echo \"Merging extracted architectures: ${ARCHS}\"\n lipo -o \"$FRAMEWORK_EXECUTABLE_PATH-merged\" -create \"${EXTRACTED_ARCHS[@]}\"\n rm \"${EXTRACTED_ARCHS[@]}\"\n\n echo \"Replacing original executable with thinned version\"\n rm \"$FRAMEWORK_EXECUTABLE_PATH\"\n mv \"$FRAMEWORK_EXECUTABLE_PATH-merged\" \"$FRAMEWORK_EXECUTABLE_PATH\"\n\ndone", "language": "shell" } ] } [/block] * Do not forget to check your project’s *“Frameworks Search Paths”* in your Build Settings. Make sure that the path for **Pubnative.framework** is provided correctly. [block:api-header] { "title": "Banner integration instructions" } [/block] # Creating the Banner The **PNBanner** should be created inside a script which is linked to a **GameObject**. It must be created using the PNBannerFactory **`createBanner()`** method which created a banner based on the platform that the application is being built for. [block:code] { "codes": [ { "code": "public static PNBanner createBanner(MonoBehaviour parent) ", "language": "csharp" } ] } [/block] A sample of this instantiation is the following: [block:code] { "codes": [ { "code": "PNBanner banner = PNBannerFactory.createBanner(this);", "language": "csharp" } ] } [/block] In the previous sample **`this`** is an object which inherits from MonoBehaviour so it’s linked to a **GameObject**. After creating the Banner you must set the **appToken** and **placement** properties: [block:code] { "codes": [ { "code": "banner.appToken = “App Token obtained from PubNative dashboard”;\nbanner.placement = “Placement Name configured and obtained from the PubNative Dashboard”;", "language": "csharp" } ] } [/block] Setting the listeners is also recommended to check the correct behavior of the ads. There are two listeners for **PNBanner**: **`ILoadListener()`** and **`ITrackListener()`**. [block:code] { "codes": [ { "code": "public interface ILoadListener\n{\n void OnLoadFinished();\n void OnLoadFailed(Exception error);\n} \n\npublic interface ITrackListener\n{\n void OnImpressionTracked();\n void OnClickTracked();\n} ", "language": "csharp" } ] } [/block] Adding a **LoadListener** to the **PNBanner** is mandatory since it will send callbacks when the ad was loaded or failed. After the ad is loaded then it can be displayed. **TrackListener** is optional in case you want to receive callbacks when the ad has been impressed on screen or when the ad has been clicked. Here’s an implementation sample: [block:code] { "codes": [ { "code": "banner.LoadListener = LOAD_LISTENER_INSTANCE;\nbanner.TrackListener = TRACK_LISTENER_INSTANCE;", "language": "csharp" } ] } [/block] # Loading the banner To load the Banner you should use the **`Load()`** method. This method must be invoked in the following way: [block:code] { "codes": [ { "code": "banner.Load(); ", "language": "csharp" } ] } [/block] The result of this method will be received in the **LoadListener** callbacks. # Showing the banner The Banner can be displayed in two positions on the screen: TOP or BOTTOM. After the ad is loaded successfully, the **`Show(Position position)`** method must be used to display the ad. Here’s are samples of how to show the Banner on top or bottom of the screen. [block:code] { "codes": [ { "code": "banner.Show(PNBanner.Position.TOP); \nbanner.Show(PNBanner.Position.BOTTOM); ", "language": "csharp" } ] } [/block] _**Keep in mind, this method should be called always after receiving confirmation that the ad was loaded successfully. Otherwise, it’ll result in an error and nothing will be displayed.**_ # Code sample Here is a complete code sample about how you can integrate the Banner. [block:code] { "codes": [ { "code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\nusing UnityEngine.UI;\n\npublic class BannerNative : MonoBehaviour, ILoadListener, ITrackListener\n{\n private PNBanner banner;\n\n public string appToken;\n public string placement;\n\n [SerializeField]\n private Button _buttonLoadBanner;\n\n [SerializeField]\n private Button _buttonHideBanner;\n\n // Use this for initialization\n void Start()\n {\n banner = PNBannerFactory.createBanner(this);\n banner.appToken = appToken;\n banner.placement = placement;\n banner.LoadListener = this;\n banner.TrackListener = this;\n _buttonLoadBanner.onClick.AddListener(RequestBanner);\n _buttonHideBanner.onClick.AddListener(HideBanner);\n }\n\n private void RequestBanner()\n {\n if (banner != null) {\n banner.Load();\n }\n }\n\n private void HideBanner()\n {\n banner.Hide();\n }\n\n public void OnLoadFinished()\n {\n banner.Show(PNBanner.Position.TOP);\n }\n\n public void OnLoadFailed(Exception error)\n {\n // Handle error\n }\n\n public void OnImpressionTracked()\n {\n // Handle Impression\n }\n\n public void OnClickTracked()\n {\n // Handle Click\n }\n} ", "language": "csharp" } ] } [/block] [block:api-header] { "title": "Interstitial integration instructions" } [/block] # Creating the Interstitial The **PNInterstitial** should be created inside a script which is linked to a **GameObject**. It must be created using the PNInterstitialFactory **`createInterstitial()`** method which created an interstitial based on the platform that the application is being built for. [block:code] { "codes": [ { "code": "public static PNInterstitial createInterstitial(MonoBehaviour parent) ", "language": "csharp" } ] } [/block] A sample of this instantiation is the following: [block:code] { "codes": [ { "code": "PNInterstitial interstitial = PNInterstitialFactory.createInterstitial(this); ", "language": "csharp" } ] } [/block] In the previous sample **`this`** is an object which inherits from MonoBehaviour so it’s linked to a **GameObject**. After creating the Interstitial you must set the **appToken** and **placement** properties: [block:code] { "codes": [ { "code": "interstitial.appToken = “App Token obtained from PubNative dashboard”;\ninterstitial.placement = “Placement Name configured and obtained from the PubNative Dashboard”;", "language": "csharp" } ] } [/block] Setting the listeners is also recommended to check the correct behavior of the ads. There are three listeners for **PNInterstitial**: **`ILoadListener()`**, **`ITrackListener()`** and **`IViewListener()`**. [block:code] { "codes": [ { "code": "public interface ILoadListener\n{\n void OnLoadFinished();\n void OnLoadFailed(Exception error);\n} \n\npublic interface ITrackListener\n{\n void OnImpressionTracked();\n void OnClickTracked();\n} \n\npublic interface IViewListener\n{\n void OnShown();\n void OnHidden();\n} ", "language": "csharp" } ] } [/block] Adding a **LoadListener** to the **PNInterstitial** is mandatory since it will send callbacks when the ad was loaded or failed. After the ad is loaded then it can be displayed. **TrackListener** is optional in case you want to receive callbacks when the ad has been impressed on screen or when the ad has been clicked. **ViewListener** is optional in case you want to receive callbacks when the Interstitial has been shown and hidden. Here’s an implementation sample: [block:code] { "codes": [ { "code": "interstitial.LoadListener = LOAD_LISTENER_INSTANCE;\ninterstitial.TrackListener = TRACK_LISTENER_INSTANCE; \ninterstitial.ViewListener = VIEW_LISTENER_INSTANCE;", "language": "csharp" } ] } [/block] # Loading the interstitial To load the Interstitial you should use the **`Load()`** method. This method must be invoked in the following way: [block:code] { "codes": [ { "code": "interstitial.Load(); ", "language": "csharp" } ] } [/block] The result of this method will be received in the **LoadListener** callbacks. # Showing the interstitial After the ad is loaded successfully, the method **`Show()`** must be used to display the ad. Here’s is the sample of how to show interstitial on screen. [block:code] { "codes": [ { "code": "interstitial.Show(); ", "language": "csharp" } ] } [/block] _**Keep in mind, this method should be called always after receiving confirmation that the ad was loaded successfully. Otherwise, it’ll result in an error and nothing will be displayed.**_ # Code sample **Here is a complete code sample about how you can integrate the Interstitial. [block:code] { "codes": [ { "code": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\nusing UnityEngine.UI;\n\npublic class InterstitialNative : MonoBehaviour, ILoadListener, ITrackListener, IViewListener\n{\n private PNInterstitial interstitial;\n\n public string appToken;\n public string placement;\n\n [SerializeField]\n private Button _buttonLoadInterstitial;\n\n // Use this for initialization\n void Start()\n {\n interstitial = PNInterstitialFactory.createInterstitial(this);\n interstitial.appToken = appToken;\n interstitial.placement = placement;\n interstitial.LoadListener = this;\n interstitial.TrackListener = this;\n interstitial.ViewListener = this;\n _buttonLoadInterstitial.onClick.AddListener(RequestInterstitial);\n }\n\n private void RequestInterstitial()\n {\n if (interstitial != null) {\n interstitial.Load();\n }\n }\n\n public void OnLoadFinished()\n {\n interstitial.Show();\n }\n\n public void OnLoadFailed(Exception error)\n {\n // Handle error\n }\n\n public void OnImpressionTracked()\n {\n // Handle Impression\n }\n\n public void OnClickTracked()\n {\n // Handle Click\n }\n\n public void OnShown()\n {\n // Handle interstitial show\n }\n\n public void OnHidden()\n {\n // Handle interstitial hide\n }\n}", "language": "csharp" } ] } [/block] [block:api-header] { "title": "Demo app" } [/block] Here is [the demo project](https://drive.google.com/file/d/1XDDMR6tMDlGhGmn4KWL2qrPfdt0OBOtg/view?usp=sharing) for unity and the generated iOS project.