Chartboost.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. //
  2. // Chartboost.h
  3. // Chartboost
  4. //
  5. // Copyright 2018 Chartboost. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import <UIKit/UIKit.h>
  9. #import "ChartboostDelegate.h"
  10. @class CBInPlay;
  11. @interface Chartboost : NSObject
  12. #pragma mark - Main Chartboost API
  13. /*!
  14. @abstract
  15. Start Chartboost with required appId, appSignature and delegate.
  16. @param appId The Chartboost application ID for this application.
  17. @param appSignature The Chartboost application signature for this application.
  18. @param delegate The delegate instance to receive Chartboost SDK callbacks.
  19. @discussion This method must be executed before any other Chartboost SDK methods can be used.
  20. Once executed this call will also controll session tracking and background tasks
  21. used by Chartboost.
  22. */
  23. + (void)startWithAppId:(NSString*)appId
  24. appSignature:(NSString*)appSignature
  25. delegate:(id<ChartboostDelegate>)delegate;
  26. /*!
  27. @abstract
  28. Returns the version of the Chartboost SDK.
  29. */
  30. + (NSString*)getSDKVersion;
  31. /*!
  32. @abstract
  33. Set the logging level
  34. @param loggingLevel The minimum level that's going to be logged
  35. @discussion Logging by default is off.
  36. */
  37. + (void)setLoggingLevel:(CBLoggingLevel)loggingLevel;
  38. /*!
  39. @abstract
  40. Check to see if any views are visible
  41. @return YES if there is any view visible
  42. @discussion This method can be used to check if any chartboost ad's are visible on the app.
  43. */
  44. + (BOOL)isAnyViewVisible;
  45. /*!
  46. @abstract
  47. Determine if a locally cached interstitial exists for the given CBLocation.
  48. @param location The location for the Chartboost impression type.
  49. @return YES if there a locally cached interstitial, and NO if not.
  50. @discussion A return value of YES here indicates that the corresponding
  51. showInterstitial:(CBLocation)location method will present without making
  52. additional Chartboost API server requests to fetch data to present.
  53. */
  54. + (BOOL)hasInterstitial:(CBLocation)location;
  55. /*!
  56. @abstract
  57. Determine if a locally cached rewarded video exists for the given CBLocation.
  58. @param location The location for the Chartboost impression type.
  59. @return YES if there a locally cached rewarded video, and NO if not.
  60. @discussion A return value of YES here indicates that the corresponding
  61. showRewardedVideo:(CBLocation)location method will present without making
  62. additional Chartboost API server requests to fetch data to present.
  63. */
  64. + (BOOL)hasRewardedVideo:(CBLocation)location;
  65. /*!
  66. @abstract
  67. Determine if a locally cached InPlay object exists for the given CBLocation.
  68. @param location The location for the Chartboost impression type.
  69. @return YES if there a locally cached InPlay object, and NO if not.
  70. @discussion A return value of YES here indicates that the corresponding
  71. getInPlay:(CBLocation)location method will return an InPlay object without making
  72. additional Chartboost API server requests to fetch data to present.
  73. */
  74. + (BOOL)hasInPlay:(CBLocation)location;
  75. /*!
  76. @abstract
  77. Cache an interstitial at the given CBLocation.
  78. @param location The location for the Chartboost impression type.
  79. @discussion This method will first check if there is a locally cached interstitial
  80. for the given CBLocation and, if found, will do nothing. If no locally cached data exists
  81. the method will attempt to fetch data from the Chartboost API server.
  82. */
  83. + (void)cacheInterstitial:(CBLocation)location;
  84. /*!
  85. @abstract
  86. Present an interstitial for the given CBLocation.
  87. @param location The location for the Chartboost impression type.
  88. @discussion This method will first check if there is a locally cached interstitial
  89. for the given CBLocation and, if found, will present using the locally cached data.
  90. If no locally cached data exists the method will attempt to fetch data from the
  91. Chartboost API server and present it. If the Chartboost API server is unavailable
  92. or there is no eligible interstitial to present in the given CBLocation this method
  93. is a no-op.
  94. */
  95. + (void)showInterstitial:(CBLocation)location;
  96. /*!
  97. @abstract
  98. Cache a rewarded video at the given CBLocation.
  99. @param location The location for the Chartboost impression type.
  100. @discussion This method will first check if there is a locally cached rewarded video
  101. for the given CBLocation and, if found, will do nothing. If no locally cached data exists
  102. the method will attempt to fetch data from the Chartboost API server.
  103. */
  104. + (void)cacheRewardedVideo:(CBLocation)location;
  105. /*!
  106. @abstract
  107. Present a rewarded video for the given CBLocation.
  108. @param location The location for the Chartboost impression type.
  109. @discussion This method will first check if there is a locally cached rewarded video
  110. for the given CBLocation and, if found, will present it using the locally cached data.
  111. If no locally cached data exists the method will attempt to fetch data from the
  112. Chartboost API server and present it. If the Chartboost API server is unavailable
  113. or there is no eligible rewarded video to present in the given CBLocation this method
  114. is a no-op.
  115. */
  116. + (void)showRewardedVideo:(CBLocation)location;
  117. /*!
  118. @abstract
  119. Cache a number of InPlay objects for the given CBLocation.
  120. @param location The location for the Chartboost impression type.
  121. @discussion This method will first check if there is a locally cached InPlay object set
  122. for the given CBLocation and, if found, will do nothing. If no locally cached data exists
  123. the method will attempt to fetch data from the Chartboost API server.
  124. */
  125. + (void)cacheInPlay:(CBLocation)location;
  126. /*!
  127. @abstract
  128. Return an InPlay object for the given CBLocation.
  129. @param location The location for the Chartboost impression type.
  130. @return CBInPlay object if one exists in the InPlay cache or nil if one is not yet available.
  131. @discussion This method will first check if there is a locally cached InPlay object
  132. for the given CBLocation and, if found, will return the object using the locally cached data.
  133. If no locally cached data exists the method will attempt to fetch data from the
  134. Chartboost API server. If the Chartboost API server is unavailable
  135. or there is no eligible InPlay object to present in the given CBLocation this method
  136. is a no-op.
  137. */
  138. + (CBInPlay *)getInPlay:(CBLocation)location;
  139. #pragma mark - Advanced Configuration & Use
  140. /*!
  141. @abstract
  142. Set the Chartboost Delegate
  143. @param del The new Chartboost Delegate for the sharedChartboost instance
  144. @discussion This doesn't need to be called when calling startWithAppID, only later
  145. to switch the delegate object.
  146. */
  147. + (void)setDelegate:(id<ChartboostDelegate>)del;
  148. /*!
  149. @abstract
  150. Confirm if an age gate passed or failed. When specified Chartboost will wait for
  151. this call before showing the IOS App Store.
  152. @param pass The result of successfully passing the age confirmation.
  153. @discussion If you have configured your Chartboost experience to use the age gate feature
  154. then this method must be executed after the user has confirmed their age. The Chartboost SDK
  155. will halt until this is done.
  156. */
  157. + (void)didPassAgeGate:(BOOL)pass;
  158. /*!
  159. @abstract
  160. Opens a "deep link" URL for a Chartboost Custom Scheme.
  161. @param url The URL to open.
  162. @param sourceApplication The application that originated the action.
  163. @return YES if Chartboost SDK is capable of handling the URL and does so, and NO if not.
  164. @discussion If you have configured a custom scheme and provided "deep link" URLs that the
  165. Chartboost SDK is capable of handling you should use this method in your ApplicationDelegate
  166. class methods that handle custom URL schemes.
  167. */
  168. + (BOOL)handleOpenURL:(NSURL *)url
  169. sourceApplication:(NSString *)sourceApplication;
  170. /*!
  171. @abstract
  172. Opens a "deep link" URL for a Chartboost Custom Scheme.
  173. @param url The URL to open.
  174. @param sourceApplication The application that originated the action.
  175. @param annotation The provided annotation.
  176. @return YES if Chartboost SDK is capable of handling the URL and does so, and NO if not.
  177. @discussion If you have configured a custom scheme and provided "deep link" URLs that the
  178. Chartboost SDK is capable of handling you should use this method in your ApplicationDelegate
  179. class methods that handle custom URL schemes.
  180. */
  181. + (BOOL)handleOpenURL:(NSURL *)url
  182. sourceApplication:(NSString *)sourceApplication
  183. annotation:(id)annotation;
  184. /*!
  185. @abstract
  186. Set a custom identifier to send in the POST body for all Chartboost API server requests.
  187. @param customId The identifier to send with all Chartboost API server requests.
  188. @discussion Use this method to set a custom identifier that can be used later in the Chartboost
  189. dashboard to group information by.
  190. */
  191. + (void)setCustomId:(NSString *)customId;
  192. /*!
  193. @abstract
  194. Get the current custom identifier being sent in the POST body for all Chartboost API server requests.
  195. @return The identifier being sent with all Chartboost API server requests.
  196. @discussion Use this method to get the custom identifier that can be used later in the Chartboost
  197. dashboard to group information by.
  198. */
  199. + (NSString *)getCustomId;
  200. /*!
  201. @abstract
  202. Set a custom version to append to the POST body of every request. This is useful for analytics and provides chartboost with important information.
  203. example: [Chartboost setChartboostWrapperVersion:@"6.4.6"];
  204. @param chartboostWrapperVersion The version sent as a string.
  205. @discussion This is an internal method used via Chartboost's Unity and Corona SDKs
  206. to track their usage.
  207. */
  208. + (void)setChartboostWrapperVersion:(NSString*)chartboostWrapperVersion;
  209. /*!
  210. @abstract
  211. Set a custom framework suffix to append to the POST headers field.
  212. example setFramework:Unity withVersion:4.6, setFrameworkVersion:5.2.1
  213. @param framework The suffix to send with all Chartbooost API server requets.
  214. @param version The platform version used for analytics. Example Unity should set Application.unityVersion
  215. @discussion This is an internal method used via Chartboost's Unity and Corona SDKs
  216. to track their usage.
  217. */
  218. + (void)setFramework:(CBFramework)framework withVersion:(NSString *)version;
  219. /*!
  220. @abstract
  221. Set a custom mediation library to append to the POST body of every request.
  222. example setMediation:CBMediationMoPub withVersion:@"3.8.0"
  223. @param library The constant for the name of the mediation library.
  224. @param libraryVersion The version sent as a string.
  225. @discussion This is an internal method used by mediation partners to track their usage.
  226. */
  227. + (void)setMediation:(CBMediation)library withVersion:(NSString*)libraryVersion;
  228. /*!
  229. @abstract
  230. Decide if Chartboost SDK should show interstitials in the first session.
  231. @param shouldRequest YES if allowed to show interstitials in first session, NO otherwise.
  232. @discussion Set to control if Chartboost SDK can show interstitials in the first session.
  233. The session count is controlled via the startWithAppId:appSignature:delegate: method in the Chartboost
  234. class.
  235. Default is YES.
  236. */
  237. + (void)setShouldRequestInterstitialsInFirstSession:(BOOL)shouldRequest;
  238. /*!
  239. @abstract
  240. Decide if Chartboost SDK should block for an age gate.
  241. @param shouldPause YES if Chartboost should pause for an age gate, NO otherwise.
  242. @discussion Set to control if Chartboost SDK should block for an age gate.
  243. Default is NO.
  244. */
  245. + (void)setShouldPauseClickForConfirmation:(BOOL)shouldPause;
  246. /*!
  247. @abstract
  248. Decide if Chartboost SDKK will attempt to fetch videos from the Chartboost API servers.
  249. @param shouldPrefetch YES if Chartboost should prefetch video content, NO otherwise.
  250. @discussion Set to control if Chartboost SDK control if videos should be prefetched.
  251. Default is YES.
  252. */
  253. + (void)setShouldPrefetchVideoContent:(BOOL)shouldPrefetch;
  254. /*!
  255. @abstract
  256. Set to enable and disable the auto cache feature (Enabled by default).
  257. @param shouldCache The param to enable or disable auto caching.
  258. @discussion If set to YES the Chartboost SDK will automatically attempt to cache an impression
  259. once one has been consumed via a "show" call. If set to NO, it is the responsibility of the
  260. developer to manage the caching behavior of Chartboost impressions.
  261. */
  262. + (void)setAutoCacheAds:(BOOL)shouldCache;
  263. /*!
  264. @abstract
  265. Get the current auto cache behavior (Enabled by default).
  266. @return YES if the auto cache is enabled, NO if it is not.
  267. @discussion If set to YES the Chartboost SDK will automatically attempt to cache an impression
  268. once one has been consumed via a "show" call. If set to NO, it is the responsibility of the
  269. developer to manage the caching behavior of Chartboost impressions.
  270. */
  271. + (BOOL)getAutoCacheAds;
  272. /*!
  273. @abstract
  274. Set to control how the fullscreen ad units should interact with the status bar. (CBStatusBarBehaviorIgnore by default).
  275. @param statusBarBehavior The param to set if fullscreen video should respect the status bar.
  276. @discussion See the enum value comments for descriptions on the values and their behavior. Only use this feature if your
  277. application has the status bar enabled.
  278. */
  279. + (void)setStatusBarBehavior:(CBStatusBarBehavior)statusBarBehavior;
  280. /*!
  281. @abstract
  282. returns YES if auto IAP tracking is enabled, NO if it isn't.
  283. @discussion Call to check if automatic tracking of in-app purchases is enabled.
  284. The setting is controlled by the server.
  285. */
  286. + (BOOL)getAutoIAPTracking;
  287. /*!
  288. @abstract
  289. Mute/unmute chartboost ads.
  290. @param mute YES all sounds, NO activates them. Default is NO
  291. @discussion default value is NO
  292. */
  293. + (void)setMuted:(BOOL)mute;
  294. /*!
  295. @abstract
  296. Set to restrict Chartboost's ability to collect personal data from the device. See CBPIDataUseConsent declaration for details
  297. Note: This method should be called before starting the Chartboost SDK with startWithAppId:appSignature:delegate.
  298. @param consent: set the consent level
  299. @discussion Default value is Unknown
  300. */
  301. + (void)setPIDataUseConsent:(CBPIDataUseConsent)consent;
  302. /*!
  303. @abstract
  304. Get the current consent setting
  305. */
  306. + (CBPIDataUseConsent)getPIDataUseConsent;
  307. #pragma mark - Deprecated
  308. + (void)restrictDataCollection:(BOOL)shouldRestrict __attribute__((deprecated("Use setPIDataUseConsent:(CBPIDataUseConsent)consent instead")));
  309. + (BOOL)hasMoreApps:(CBLocation)location __attribute__((deprecated("This method is deprecated will always return false")));
  310. + (void)showMoreApps:(CBLocation)location __attribute__((deprecated("This method is deprecated and is a no-op")));
  311. + (void)showMoreApps:(UIViewController *)viewController
  312. location:(CBLocation)location __attribute__((deprecated("This method is deprecated and is a no-op")));
  313. + (void)setShouldDisplayLoadingViewForMoreApps:(BOOL)shouldDisplay __attribute__((deprecated("This method is deprecated and is a no-op")));
  314. + (void)cacheMoreApps:(CBLocation)location __attribute__((deprecated("This method is deprecated and is a no-op")));
  315. @end