ChartboostDelegate.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. //
  2. // ChartboostDelegate.h
  3. // Chartboost
  4. //
  5. // Copyright 2018 Chartboost. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. @class UIView;
  9. /*!
  10. @typedef NS_ENUM (NSUInteger, CBLogLevel)
  11. @abstract
  12. Set logging level. Default is OFF
  13. */
  14. typedef NS_ENUM(NSUInteger, CBLoggingLevel) {
  15. /*! Logging Off. */
  16. CBLoggingLevelOff,
  17. /*! Verbose. */
  18. CBLoggingLevelVerbose,
  19. /*! Info. */
  20. CBLoggingLevelInfo,
  21. /*! Warning. */
  22. CBLoggingLevelWarning,
  23. /*! Error. */
  24. CBLoggingLevelError,
  25. };
  26. /*!
  27. @typedef NS_ENUM (NSUInteger, CBFramework)
  28. @abstract
  29. Used with setFramework:(CBFramework)framework calls to set suffix for
  30. wrapper libraries like Unity or Corona.
  31. */
  32. typedef NS_ENUM(NSUInteger, CBFramework) {
  33. /*! Unity. */
  34. CBFrameworkUnity,
  35. /*! Corona. */
  36. CBFrameworkCorona,
  37. /*! Adobe AIR. */
  38. CBFrameworkAIR,
  39. /*! GameSalad. */
  40. CBFrameworkGameSalad,
  41. /*! Cordova. */
  42. CBFrameworkCordova,
  43. /*! CocoonJS. */
  44. CBFrameworkCocoonJS,
  45. /*! Cocos2d-x. */
  46. CBFrameworkCocos2dx,
  47. /*! Prime31Unreal. */
  48. CBFrameworkPrime31Unreal,
  49. /*! Weeby. */
  50. CBFrameworkWeeby,
  51. /*! Unknown. Other */
  52. CBFrameworkOther
  53. };
  54. /*!
  55. @typedef NS_ENUM (NSUInteger, CBMediation)
  56. @abstract
  57. Used with setMediation:(CBMediation)library calls to set mediation library name
  58. partners. If you don't see your library here, contact support.
  59. */
  60. typedef NS_ENUM(NSUInteger, CBMediation) {
  61. /*! Unknown. Other */
  62. CBMediationOther,
  63. /*! AdMarvel */
  64. CBMediationAdMarvel,
  65. /*! Fuse */
  66. CBMediationFuse,
  67. /*! Fyber */
  68. CBMediationFyber,
  69. /*! HeyZap */
  70. CBMediationHeyZap,
  71. /*! MoPub */
  72. CBMediationMoPub,
  73. /*! Supersonic */
  74. CBMediationSupersonic,
  75. /*! AdMob */
  76. CBMediationAdMob,
  77. /*! HyprMX */
  78. CBMediationHyprMX,
  79. /*! AerServ */
  80. CBMediationAerServ
  81. };
  82. /*!
  83. @typedef NS_ENUM (NSUInteger, CBLoadError)
  84. @abstract
  85. Returned to ChartboostDelegate methods to notify of Chartboost SDK errors.
  86. */
  87. typedef NS_ENUM(NSUInteger, CBLoadError) {
  88. /*! Unknown internal error. */
  89. CBLoadErrorInternal = 0,
  90. /*! Network is currently unavailable. */
  91. CBLoadErrorInternetUnavailable = 1,
  92. /*! Too many requests are pending for that location. */
  93. CBLoadErrorTooManyConnections = 2,
  94. /*! Interstitial loaded with wrong orientation. */
  95. CBLoadErrorWrongOrientation = 3,
  96. /*! Interstitial disabled, first session. */
  97. CBLoadErrorFirstSessionInterstitialsDisabled = 4,
  98. /*! Network request failed. */
  99. CBLoadErrorNetworkFailure = 5,
  100. /*! No ad received. */
  101. CBLoadErrorNoAdFound = 6,
  102. /*! Session not started. */
  103. CBLoadErrorSessionNotStarted = 7,
  104. /*! There is an impression already visible.*/
  105. CBLoadErrorImpressionAlreadyVisible = 8,
  106. /*! User manually cancelled the impression. */
  107. CBLoadErrorUserCancellation = 10,
  108. /*! No location detected. */
  109. CBLoadErrorNoLocationFound = 11,
  110. /*! Error downloading asset. */
  111. CBLoadErrorAssetDownloadFailure = 16,
  112. /*! Video Prefetching is not finished */
  113. CBLoadErrorPrefetchingIncomplete = 21,
  114. /*! Error Originating from the JS side of a Web View */
  115. CBLoadErrorWebViewScriptError = 22,
  116. /*! Network is unavailable while attempting to show. */
  117. CBLoadErrorInternetUnavailableAtShow = 25
  118. };
  119. /*!
  120. @typedef NS_ENUM (NSUInteger, CBClickError)
  121. @abstract
  122. Returned to ChartboostDelegate methods to notify of Chartboost SDK errors.
  123. */
  124. typedef NS_ENUM(NSUInteger, CBClickError) {
  125. /*! Invalid URI. */
  126. CBClickErrorUriInvalid,
  127. /*! The device does not know how to open the protocol of the URI */
  128. CBClickErrorUriUnrecognized,
  129. /*! User failed to pass the age gate. */
  130. CBClickErrorAgeGateFailure,
  131. /*! Unknown internal error */
  132. CBClickErrorInternal,
  133. };
  134. /*!
  135. @typedef NS_ENUM (NSUInteger, CBStatusBarBehavior)
  136. @abstract
  137. Used with setStatusBarBehavior:(CBStatusBarBehavior)statusBarBehavior calls to set how fullscreen ads should
  138. behave with regards to the status bar.
  139. */
  140. typedef NS_ENUM(NSUInteger, CBStatusBarBehavior) {
  141. /*! Ignore status bar altogether; fullscreen ads will use the space of the status bar. */
  142. CBStatusBarBehaviorIgnore,
  143. /*! Respect the status bar partially; fullscreen ads will use the space of the status bar but any user interactive buttons will not. */
  144. CBStatusBarBehaviorRespectButtons,
  145. /*! Respect the status bar fully; fullscreen ads will not use the status bar space. */
  146. CBStatusBarBehaviorRespect
  147. };
  148. /*!
  149. @typedef NS_ENUM (NSUInteger, CBPIDataUseConsent)
  150. @abstract
  151. GDPR compliance settings:
  152. */
  153. typedef NS_ENUM(NSInteger, CBPIDataUseConsent) {
  154. /*! Publisher hasn't implemented functionality or the user has the option to not answer. */
  155. Unknown = -1,
  156. /*! User does not consent to targeting (Contextual ads). */
  157. NoBehavioral = 0,
  158. /*! User consents (Behavioral and Contextual Ads). */
  159. YesBehavioral = 1
  160. };
  161. /*!
  162. @typedef CBLocation
  163. @abstract
  164. Defines standard locations to describe where Chartboost SDK features appear in game.
  165. @discussion Standard locations used to describe where Chartboost features show up in your game
  166. For best performance, it is highly recommended to use standard locations.
  167. Benefits include:
  168. - Higher eCPMs.
  169. - Control of ad targeting and frequency.
  170. - Better reporting.
  171. */
  172. typedef NSString * const CBLocation;
  173. /*! "Startup" - Initial startup of game. */
  174. FOUNDATION_EXPORT CBLocation const CBLocationStartup;
  175. /*! "Home Screen" - Home screen the player first sees. */
  176. FOUNDATION_EXPORT CBLocation const CBLocationHomeScreen;
  177. /*! "Main Menu" - Menu that provides game options. */
  178. FOUNDATION_EXPORT CBLocation const CBLocationMainMenu;
  179. /*! "Game Screen" - Game screen where all the magic happens. */
  180. FOUNDATION_EXPORT CBLocation const CBLocationGameScreen;
  181. /*! "Achievements" - Screen with list of achievements in the game. */
  182. FOUNDATION_EXPORT CBLocation const CBLocationAchievements;
  183. /*! "Quests" - Quest, missions or goals screen describing things for a player to do. */
  184. FOUNDATION_EXPORT CBLocation const CBLocationQuests;
  185. /*! "Pause" - Pause screen. */
  186. FOUNDATION_EXPORT CBLocation const CBLocationPause;
  187. /*! "Level Start" - Start of the level. */
  188. FOUNDATION_EXPORT CBLocation const CBLocationLevelStart;
  189. /*! "Level Complete" - Completion of the level */
  190. FOUNDATION_EXPORT CBLocation const CBLocationLevelComplete;
  191. /*! "Turn Complete" - Finishing a turn in a game. */
  192. FOUNDATION_EXPORT CBLocation const CBLocationTurnComplete;
  193. /*! "IAP Store" - The store where the player pays real money for currency or items. */
  194. FOUNDATION_EXPORT CBLocation const CBLocationIAPStore;
  195. /*! "Item Store" - The store where a player buys virtual goods. */
  196. FOUNDATION_EXPORT CBLocation const CBLocationItemStore;
  197. /*! "Game Over" - The game over screen after a player is finished playing. */
  198. FOUNDATION_EXPORT CBLocation const CBLocationGameOver;
  199. /*! "Leaderboard" - List of leaders in the game. */
  200. FOUNDATION_EXPORT CBLocation const CBLocationLeaderBoard;
  201. /*! "Settings" - Screen where player can change settings such as sound. */
  202. FOUNDATION_EXPORT CBLocation const CBLocationSettings;
  203. /*! "Quit" - Screen displayed right before the player exits a game. */
  204. FOUNDATION_EXPORT CBLocation const CBLocationQuit;
  205. /*! "Default" - Supports legacy applications that only have one "Default" location */
  206. FOUNDATION_EXPORT CBLocation const CBLocationDefault;
  207. /*!
  208. @protocol ChartboostDelegate
  209. @abstract
  210. Provide methods and callbacks to receive notifications of when the Chartboost SDK
  211. has taken specific actions or to more finely control the Chartboost SDK.
  212. @discussion For more information on integrating and using the Chartboost SDK
  213. please visit our help site documentation at https://help.chartboost.com
  214. All of the delegate methods are optional.
  215. */
  216. @protocol ChartboostDelegate <NSObject>
  217. @optional
  218. /*!
  219. @abstract
  220. Called by the SDK to show customized AgeGate View.
  221. @return A valid UIView. Reutrn nil if no customized Age Gate is needed.
  222. @discussion SDK will call this method to see if user wants to implement their own custom age gate view.
  223. Check for didPassAgeGate for other details.
  224. */
  225. - (UIView*)customAgeGateView;
  226. /*!
  227. @abstract
  228. Called after the SDK has been successfully initialized
  229. @param status The result of the initialization. YES if successful. NO if failed.
  230. @discussion Implement to be notified of when the initialization process has finished.
  231. */
  232. - (void)didInitialize:(BOOL)status;
  233. #pragma mark - Interstitial Delegate
  234. /*!
  235. @abstract
  236. Called before requesting an interstitial via the Chartboost API server.
  237. @param location The location for the Chartboost impression type.
  238. @return YES if execution should proceed, NO if not.
  239. @discussion Implement to control if the Charboost SDK should fetch data from
  240. the Chartboost API servers for the given CBLocation. This is evaluated
  241. if the showInterstitial:(CBLocation) or cacheInterstitial:(CBLocation)location
  242. are called. If YES is returned the operation will proceed, if NO, then the
  243. operation is treated as a no-op.
  244. Default return is YES.
  245. */
  246. - (BOOL)shouldRequestInterstitial:(CBLocation)location;
  247. /*!
  248. @abstract
  249. Called before an interstitial will be displayed on the screen.
  250. @param location The location for the Chartboost impression type.
  251. @return YES if execution should proceed, NO if not.
  252. @discussion Implement to control if the Charboost SDK should display an interstitial
  253. for the given CBLocation. This is evaluated if the showInterstitial:(CBLocation)
  254. is called. If YES is returned the operation will proceed, if NO, then the
  255. operation is treated as a no-op and nothing is displayed.
  256. Default return is YES.
  257. */
  258. - (BOOL)shouldDisplayInterstitial:(CBLocation)location;
  259. /*!
  260. @abstract
  261. Called after an interstitial has been displayed on the screen.
  262. @param location The location for the Chartboost impression type.
  263. @discussion Implement to be notified of when an interstitial has
  264. been displayed on the screen for a given CBLocation.
  265. */
  266. - (void)didDisplayInterstitial:(CBLocation)location;
  267. /*!
  268. @abstract
  269. Called after an interstitial has been loaded from the Chartboost API
  270. servers and cached locally.
  271. @param location The location for the Chartboost impression type.
  272. @discussion Implement to be notified of when an interstitial has been loaded from the Chartboost API
  273. servers and cached locally for a given CBLocation.
  274. */
  275. - (void)didCacheInterstitial:(CBLocation)location;
  276. /*!
  277. @abstract
  278. Called after an interstitial has attempted to load from the Chartboost API
  279. servers but failed.
  280. @param location The location for the Chartboost impression type.
  281. @param error The reason for the error defined via a CBLoadError.
  282. @discussion Implement to be notified of when an interstitial has attempted to load from the Chartboost API
  283. servers but failed for a given CBLocation.
  284. */
  285. - (void)didFailToLoadInterstitial:(CBLocation)location
  286. withError:(CBLoadError)error;
  287. /*!
  288. @abstract
  289. Called after a click is registered, but the user is not fowrwarded to the IOS App Store.
  290. @param location The location for the Chartboost impression type.
  291. @param error The reason for the error defined via a CBLoadError.
  292. @discussion Implement to be notified of when a click is registered, but the user is not fowrwarded
  293. to the IOS App Store for a given CBLocation.
  294. */
  295. - (void)didFailToRecordClick:(CBLocation)location
  296. withError:(CBClickError)error;
  297. /*!
  298. @abstract
  299. Called after an interstitial has been dismissed.
  300. @param location The location for the Chartboost impression type.
  301. @discussion Implement to be notified of when an interstitial has been dismissed for a given CBLocation.
  302. "Dismissal" is defined as any action that removed the interstitial UI such as a click or close.
  303. */
  304. - (void)didDismissInterstitial:(CBLocation)location;
  305. /*!
  306. @abstract
  307. Called after an interstitial has been closed.
  308. @param location The location for the Chartboost impression type.
  309. @discussion Implement to be notified of when an interstitial has been closed for a given CBLocation.
  310. "Closed" is defined as clicking the close interface for the interstitial.
  311. */
  312. - (void)didCloseInterstitial:(CBLocation)location;
  313. /*!
  314. @abstract
  315. Called after an interstitial has been clicked.
  316. @param location The location for the Chartboost impression type.
  317. @discussion Implement to be notified of when an interstitial has been click for a given CBLocation.
  318. "Clicked" is defined as clicking the creative interface for the interstitial.
  319. */
  320. - (void)didClickInterstitial:(CBLocation)location;
  321. #pragma mark - Rewarded Video Delegate
  322. /*!
  323. @abstract
  324. Called before a rewarded video will be displayed on the screen.
  325. @param location The location for the Chartboost impression type.
  326. @return YES if execution should proceed, NO if not.
  327. @discussion Implement to control if the Charboost SDK should display a rewarded video
  328. for the given CBLocation. This is evaluated if the showRewardedVideo:(CBLocation)
  329. is called. If YES is returned the operation will proceed, if NO, then the
  330. operation is treated as a no-op and nothing is displayed.
  331. Default return is YES.
  332. */
  333. - (BOOL)shouldDisplayRewardedVideo:(CBLocation)location;
  334. /*!
  335. @abstract
  336. Called after a rewarded video has been displayed on the screen.
  337. @param location The location for the Chartboost impression type.
  338. @discussion Implement to be notified of when a rewarded video has
  339. been displayed on the screen for a given CBLocation.
  340. */
  341. - (void)didDisplayRewardedVideo:(CBLocation)location;
  342. /*!
  343. @abstract
  344. Called after a rewarded video has been loaded from the Chartboost API
  345. servers and cached locally.
  346. @param location The location for the Chartboost impression type.
  347. @discussion Implement to be notified of when a rewarded video has been loaded from the Chartboost API
  348. servers and cached locally for a given CBLocation.
  349. */
  350. - (void)didCacheRewardedVideo:(CBLocation)location;
  351. /*!
  352. @abstract
  353. Called after a rewarded video has attempted to load from the Chartboost API
  354. servers but failed.
  355. @param location The location for the Chartboost impression type.
  356. @param error The reason for the error defined via a CBLoadError.
  357. @discussion Implement to be notified of when an rewarded video has attempted to load from the Chartboost API
  358. servers but failed for a given CBLocation.
  359. */
  360. - (void)didFailToLoadRewardedVideo:(CBLocation)location
  361. withError:(CBLoadError)error;
  362. /*!
  363. @abstract
  364. Called after a rewarded video has been dismissed.
  365. @param location The location for the Chartboost impression type.
  366. @discussion Implement to be notified of when a rewarded video has been dismissed for a given CBLocation.
  367. "Dismissal" is defined as any action that removed the rewarded video UI such as a click or close.
  368. */
  369. - (void)didDismissRewardedVideo:(CBLocation)location;
  370. /*!
  371. @abstract
  372. Called after a rewarded video has been closed.
  373. @param location The location for the Chartboost impression type.
  374. @discussion Implement to be notified of when a rewarded video has been closed for a given CBLocation.
  375. "Closed" is defined as clicking the close interface for the rewarded video.
  376. */
  377. - (void)didCloseRewardedVideo:(CBLocation)location;
  378. /*!
  379. @abstract
  380. Called after a rewarded video has been clicked.
  381. @param location The location for the Chartboost impression type.
  382. @discussion Implement to be notified of when a rewarded video has been click for a given CBLocation.
  383. "Clicked" is defined as clicking the creative interface for the rewarded video.
  384. */
  385. - (void)didClickRewardedVideo:(CBLocation)location;
  386. /*!
  387. @abstract
  388. Called after a rewarded video has been viewed completely and user is eligible for reward.
  389. @param reward The reward for watching the video.
  390. @param location The location for the Chartboost impression type.
  391. @discussion Implement to be notified of when a rewarded video has been viewed completely and user is eligible for reward.
  392. */
  393. - (void)didCompleteRewardedVideo:(CBLocation)location
  394. withReward:(int)reward;
  395. #pragma mark - InPlay Delegate
  396. /*!
  397. @abstract
  398. Called after an InPlay object has been loaded from the Chartboost API
  399. servers and cached locally.
  400. @param location The location for the Chartboost impression type.
  401. @discussion Implement to be notified of when an InPlay object has been loaded from the Chartboost API
  402. servers and cached locally for a given CBLocation.
  403. */
  404. - (void)didCacheInPlay:(CBLocation)location;
  405. /*!
  406. @abstract
  407. Called after a InPlay has attempted to load from the Chartboost API
  408. servers but failed.
  409. @param location The location for the Chartboost impression type.
  410. @param error The reason for the error defined via a CBLoadError.
  411. @discussion Implement to be notified of when an InPlay has attempted to load from the Chartboost API
  412. servers but failed for a given CBLocation.
  413. */
  414. - (void)didFailToLoadInPlay:(CBLocation)location
  415. withError:(CBLoadError)error;
  416. #pragma mark - General Delegate
  417. /*!
  418. @abstract
  419. Called before an interstitial has been displayed on the screen.
  420. @param location The location for the Chartboost impression type.
  421. @discussion Implement to be notified of when an interstitial will
  422. be displayed on the screen for a given CBLocation.
  423. */
  424. - (void)willDisplayInterstitial:(CBLocation)location;
  425. /*!
  426. @abstract
  427. Called before a video has been displayed on the screen.
  428. @param location The location for the Chartboost impression type.
  429. @discussion Implement to be notified of when a video will
  430. be displayed on the screen for a given CBLocation. You can then do things like mute
  431. effects and sounds.
  432. */
  433. - (void)willDisplayVideo:(CBLocation)location;
  434. /*!
  435. @abstract
  436. Called after the App Store sheet is dismissed, when displaying the embedded app sheet.
  437. @discussion Implement to be notified of when the App Store sheet is dismissed.
  438. */
  439. - (void)didCompleteAppStoreSheetFlow;
  440. /*!
  441. @abstract
  442. Called if Chartboost SDK pauses click actions awaiting confirmation from the user.
  443. @discussion Use this method to display any gating you would like to prompt the user for input.
  444. Once confirmed call didPassAgeGate:(BOOL)pass to continue execution.
  445. */
  446. - (void)didPauseClickForConfirmation;
  447. @end