Reference
Values
What the SDK hands back. Every value is immutable and safe to read on any thread.
NGAAd #
One loaded ad, from onLoaded. It is single-use: once shown, it is consumed.
Unity (C#)
public sealed class NGAAd : IEquatable<NGAAd>
{
public string PlacementId { get; }
public string OpportunityId { get; }
public long ExpiresAtMillis { get; }
public NGAAdState State { get; }
public bool IsReady();
public void Show(NGAAdShowListener listener); // every format
public void Close(); // the native banner
}
Android (Kotlin)
interface NGAAd {
val placementId: String
val opportunityId: String
val expiresAtMillis: Long
val state: NGAAdState
fun isReady(): Boolean
fun show(activity: Activity, listener: NGAAdShowListener) // every format
fun close() // the native banner
}
Android (Java)
String getPlacementId()
String getOpportunityId()
long getExpiresAtMillis()
NGAAdState getState()
boolean isReady()
void show(Activity activity, NGAAdShowListener listener) // every format
void close() // the native banner
iOS (Swift)
@objc protocol NGAAd {
var placementId: String { get }
var opportunityId: String { get }
var expiresAtMillis: Int64 { get }
var state: NGAAdState { get }
var isReady: Bool { get }
func show(from viewController: UIViewController, listener: NGAAdShowListener) // every format
func close() // the native banner
}
iOS (Objective-C)
@protocol NGAAd
@property (readonly) NSString *placementId;
@property (readonly) NSString *opportunityId;
@property (readonly) int64_t expiresAtMillis;
@property (readonly) NGAAdState state;
@property (readonly) BOOL isReady;
- (void)showFromViewController:(UIViewController *)viewController listener:(id<NGAAdShowListener>)listener;
- (void)close;
@end
| Member | Description |
|---|---|
placementId |
the placement it was loaded for |
opportunityId |
unique to this ad, and single-use: the id to key a reward by, and the id on its NGAImpression |
expiresAtMillis |
when it expires, in epoch milliseconds, for display only; isReady() is the check to use |
state |
NGAAdState: READY, SHOWING, CONSUMED, EXPIRED or FAILED |
isReady() |
true when state is READY and the ad has not expired; it checks nothing else |
show(activity) / show(from:) |
shows the ad in its placement's format: full screen (interstitial, rewarded) or the native banner at the bottom of that screen. C# Show(listener) uses Unity's own Activity or view controller |
close() |
ends a native banner's show: the banner slides down, then onCompleted and onClosed (onClosed alone before its impression). Nothing for a full-screen ad, or a banner that is not showing |
There is one show for every format. Every show ends in onClosed or onShowFailed and never throws; see NGAAdShowListener. state and isReady() read a snapshot and never block.
Expiry. An ad can be shown for 30 minutes after it loads. Then it expires: every load callback for it gets onExpired, isReady() is false, and show fails with EXPIRED. Load again. An ad already on screen is not affected. Time asleep counts: an ad that ran out while the device slept expires when the game comes back to the front. When NGA stops the SDK (the app key switched off, or this SDK version or build retired), every loaded ad expires at once.
NGARewardResult #
A rewarded show's outcome, through onRewardResult.
Unity (C#)
public bool Granted { get; }
public NGARewardDenial Denial { get; } // None when granted
Android (Kotlin)
val granted: Boolean
val denial: NGARewardDenial? // null when granted
Android (Java)
boolean getGranted()
NGARewardDenial getDenial() // null when granted
iOS (Swift)
let granted: Bool
let denial: NGARewardDenial // .none when granted
iOS (Objective-C)
@property (readonly) BOOL granted;
@property (readonly) NGARewardDenial denial; // NGARewardDenialNone when granted
| Field | Description |
|---|---|
granted |
true when the reward was earned |
denial |
why not, when granted is false: SKIPPED (closed before the reward was earned), INTERRUPTED (the ad stopped mid-way) or REJECTED (this ad grants no reward). Null, .none or None when granted |
Your game defines the reward; NGA has no reward type or amount.
NGAImpression #
One NGA impression and its payout, through the impression listener.
Unity (C#)
public string PlacementId { get; }
public string OpportunityId { get; }
public NGAAdFormat Format { get; }
public long RevenueMicros { get; }
public string Currency { get; }
public NGARevenuePrecision Precision { get; }
public string CampaignId { get; } // may be null
public string CreativeId { get; } // may be null
public string AdvertiserBundle { get; } // may be null
public string AdvertiserDomain { get; } // may be null
Android (Kotlin)
val placementId: String
val opportunityId: String
val format: NGAAdFormat
val revenueMicros: Long
val currency: String
val precision: NGARevenuePrecision
val campaignId: String?
val creativeId: String?
val advertiserBundle: String?
val advertiserDomain: String?
Android (Java)
String getPlacementId()
String getOpportunityId()
NGAAdFormat getFormat()
long getRevenueMicros()
String getCurrency()
NGARevenuePrecision getPrecision()
String getCampaignId() // may be null
String getCreativeId() // may be null
String getAdvertiserBundle() // may be null
String getAdvertiserDomain() // may be null
iOS (Swift)
let placementId: String
let opportunityId: String
let format: NGAAdFormat
let revenueMicros: Int64
let currency: String
let precision: NGARevenuePrecision
let campaignId: String?
let creativeId: String?
let advertiserBundle: String?
let advertiserDomain: String?
iOS (Objective-C)
@property (readonly) NSString *placementId;
@property (readonly) NSString *opportunityId;
@property (readonly) NGAAdFormat format;
@property (readonly) int64_t revenueMicros;
@property (readonly) NSString *currency;
@property (readonly) NGARevenuePrecision precision;
@property (readonly, nullable) NSString *campaignId;
@property (readonly, nullable) NSString *creativeId;
@property (readonly, nullable) NSString *advertiserBundle;
@property (readonly, nullable) NSString *advertiserDomain;
| Field | Description |
|---|---|
placementId, opportunityId |
as on the NGAAd |
format |
INTERSTITIAL, REWARDED or NATIVE (the banner) |
revenueMicros, currency |
your payout for this impression, in micros, and its three-letter currency. Cross-promotion of your own games pays 0 |
precision |
EXACT |
campaignId |
NGA's id for the campaign |
creativeId |
NGA's id for the creative, which you can quote to report or block one; null for the banner |
advertiserBundle |
the promoted game's store id: its Android package name or iOS App Store id |
advertiserDomain |
null in 0.1.0 |
NGAError #
Every failure. The codes and details are on Errors.
Unity (C#)
public NGAErrorCode Code { get; }
public string Detail { get; }
public string Message { get; }
public bool Retryable { get; }
public long? RetryAfterMillis { get; }
Android (Kotlin)
val code: NGAErrorCode
val detail: String
val message: String
val retryable: Boolean
val retryAfterMillis: Long?
val cause: Throwable?
Android (Java)
NGAErrorCode getCode()
String getDetail()
String getMessage()
boolean getRetryable()
Long getRetryAfterMillis() // may be null
Throwable getCause() // may be null
iOS (Swift)
let code: NGAErrorCode
let detail: String
let message: String
let retryable: Bool
let retryAfterMillis: Int64?
let cause: NSError?
iOS (Objective-C)
@property (readonly) NGAErrorCode code;
@property (readonly) NSString *detail;
@property (readonly) NSString *message;
@property (readonly) BOOL retryable;
@property (readonly, nullable) NSNumber *retryAfterMillis;
@property (readonly, nullable) NSError *cause;
| Field | Description |
|---|---|
code |
NGAErrorCode; the same integer on every platform |
detail |
a stable reason, such as no_fill.cap; safe to branch on |
message |
for people; may change between releases |
retryable |
whether trying again can help |
retryAfterMillis |
a sensible wait, when the SDK or the server knows one; otherwise null |
cause |
the underlying exception, when there is one; not in C# |
NGAResult #
The immediate result of a call that validates on the spot: setCustomerUserId, logAdRevenue, logPurchase.
Unity (C#)
public bool Accepted { get; }
public NGAError Error { get; } // null when accepted
Android (Kotlin)
val accepted: Boolean
val error: NGAError?
Android (Java)
boolean getAccepted()
NGAError getError() // null when accepted
iOS (Swift)
let accepted: Bool
let error: NGAError?
iOS (Objective-C)
@property (readonly) BOOL accepted;
@property (readonly, nullable) NGAError *error;
| Field | Description |
|---|---|
accepted |
true when the call is valid. It is then delivered, at least once, after an init succeeds in this process |
error |
why the call was refused; null when accepted |
NGAInitResult #
The result of initialize, through onInitialized.
Unity (C#)
public bool Success { get; }
public NGAError Error { get; } // null on success
public bool FromCache { get; }
Android (Kotlin)
val success: Boolean
val error: NGAError?
val fromCache: Boolean
Android (Java)
boolean getSuccess()
NGAError getError() // null on success
boolean getFromCache()
iOS (Swift)
let success: Bool
let error: NGAError?
let fromCache: Bool
iOS (Objective-C)
@property (readonly) BOOL success;
@property (readonly, nullable) NGAError *error;
@property (readonly) BOOL fromCache;
| Field | Description |
|---|---|
success |
true when init completed |
error |
why init failed; null on success |
fromCache |
true when init used the configuration saved at an earlier launch, online or not; a fresh one is fetched in the background |
See The answer.