# App Open

This guide is intended for publishers integrating app open ads.

App open ads are a special ad format for publishers who want to load ads on app launch. App open ads can be closed by your users at any time. Here is an example of what an app open ad looks like:

<div align="left"><figure><img src="/files/dWh2OTSOnlkskgeGw1L3" alt=""><figcaption></figcaption></figure></div>

At a high level, here are the steps required to implement app open ads:

* Add methods to your `AppDelegate` to load and display an app open ad
* Handle presentation callbacks.

### Prerequisites

* Follow the setup instructions in our[ Get Started guide](/interface-documentation/ios/get-started/getting-started-guide.md)

### Always test with test ads <a href="#always_test_with_test_ads" id="always_test_with_test_ads"></a>

When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account. The easiest way to load test ads is to use our dedicated test ad unit ID for app open ads:

```
63a57390cf26c
```

It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging. Just make sure you replace it with your own ad unit ID before publishing your app.

### Modify your app delegate <a href="#modify_your_app_delegate" id="modify_your_app_delegate"></a>

App open ads are shown when your application launches. To make sure you have an ad ready to display when a user opens your app, you'll want to have a reference to an ad ready to use.

That means you must preload an ad before you need to show the ad. That way, your app open ad is ready to show the next time the app is opened. To facilitate having a single reference to the ad, add the methods to your `AppDelegate.m`:

{% tabs %}
{% tab title="Swift" %}

```swift
func requestAppOpenAd() {
    //userId 
    Adx3FullScreenAd.sharedManager().load(withPlacementID: "Your Placement ID", userId: "", delegate: self)
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
- (void)requestAppOpenAd {
    //userId Optional
    [[Adx3FullScreenAd sharedManager] loadAdWithPlacementID:@"Your Placement ID" userId:@"" delegate:self];
}
```

{% endtab %}
{% endtabs %}

This method initiates a request to load a new ad so that the user has an ad available when they launch your app.

### Handle request callbacks

You should rely on the Adx3AdLoadingDelegate (optional) to handle request events, methods as below:

{% tabs %}
{% tab title="Swift" %}

```swift
func didFinishLoadingAD(withPlacementID placementID: String!) {
    print("----\(placementID!)----")
}
    
func didFailToLoadAD(withPlacementID placementID: String!, error: Error!) {
    print("----\(error.debugDescription)----")
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
- (void)didFinishLoadingADWithPlacementID:(NSString *)placementID {
    NSLog(@"----%@----", placementID);
}

- (void)didFailToLoadADWithPlacementID:(NSString *)placementID error:(NSError *)error {
    NSLog(@"----%@----", error.description);
}
```

{% endtab %}
{% endtabs %}

Add a method to display the ad.

{% tabs %}
{% tab title="Swift" %}

```swift
func tryToPresentAd() {
    if Adx3FullScreenAd.sharedManager().fullScreenIsReady() {
        Adx3FullScreenAd.sharedManager().showScreenView(withContrller: self, delegate: self) { isSuccess in
                
        };
    }else {
        self.requestAppOpenAd()
    } 
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
- (void)tryToPresentAd {
    if ([[Adx3FullScreenAd sharedManager] fullScreenIsReady]) {
          UIViewController *rootController = self.window.rootViewController;
          [[Adx3FullScreenAd sharedManager] showScreenViewWithContrller:rootController delegate:self success:^(BOOL isSuccess) {
            
          ];
    }else {
          // If no ad is available, make a new request
          [self requestAppOpenAd];
    }
}
```

{% endtab %}
{% endtabs %}

This method checks the presence of an ad, and if it exists and is able to be shown from your root view controller, it will present the ad over your existing content. If no ad is available the method makes a new request.

### Handle display callbacks

You should rely on the Adx3FullScreenDeleagte (optional) to handle display events, methods as below:

{% tabs %}
{% tab title="Swift" %}

```swift
func fullScreenDidStartPlayingVideo(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
}
    
func fullScreenDidEndPlayingVideo(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
}
    
func fullScreenDidFailToPlayVideo(forPlacementID placementID: String!, error: Error!, extra: [AnyHashable : Any]!) {
        
}
    
func fullScreenDidClose(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
}
    
func fullScreenDidClick(forPlacementID placementID: String!, extra: [AnyHashable : Any]!) {
        
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
-(void)fullScreenDidStartPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

-(void)fullScreenDidEndPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

-(void)fullScreenDidFailToPlayVideoForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {

}

-(void)fullScreenDidCloseForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}

-(void)fullScreenDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary*)extra {

}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.adx3.io/interface-documentation/ios/ad-formats/app-open.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
