FlurryAds.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. //
  2. // FlurryAds.h
  3. // Flurry iOS Analytics Agent
  4. //
  5. // Copyright 2009-2013 Flurry, Inc. All rights reserved.
  6. //
  7. // Methods in this header file are for use by Flurry Publishers
  8. #import <UIKit/UIKit.h>
  9. typedef enum {
  10. BANNER_TOP = 1,
  11. BANNER_BOTTOM = 2,
  12. FULLSCREEN = 3,
  13. } FlurryAdSize;
  14. @protocol FlurryCustomAdNetwork;
  15. @protocol FlurryCustomAdNetworkProperties;
  16. /*!
  17. * @brief Provides all available methods for displaying ads.
  18. *
  19. * Set of methods that allow publishers to configure, target, and deliver ads to their customers.
  20. *
  21. * @note This class depends on Flurry.h.
  22. * For information on how to use Flurry's Ads SDK to
  23. * attract high-quality users and monetize your user base see <a href="http://support.flurry.com/index.php?title=Publishers">Support Center - Publishers</a>.
  24. *
  25. * @author 2009 - 2013 Flurry, Inc. All Rights Reserved.
  26. * @version 4.3.0
  27. *
  28. */
  29. @interface FlurryAds : NSObject {
  30. }
  31. /*!
  32. * @brief Retrieves an ad for the given @c space.
  33. * @since 4.1.0
  34. *
  35. * This method will attempt to retrieve ads for the given space from the Flurry server.
  36. *
  37. * @note The @c space simply represents the placement of the ad in your app and should be
  38. * unique for each placement. For example, if you are displaying a full screen ad on your
  39. * splash screen and after level completeion, you may have the following spaces
  40. * @c @"SPLASH_AD" and @c @"LEVEL_AD".
  41. *
  42. * @see #removeAdFromSpace: for details on manually removing an ad from a view. \n
  43. * FlurryAdDelegate#spaceDidReceiveAd: for details on the notification of ads being received.
  44. * FlurryAdDelegate#spaceDidFailToReceiveAd:error: for details on notification of failure to receive ads from this request.
  45. * #displayAdForSpace: for details on displaying an available ad.
  46. *
  47. * @code
  48. * - (void)fetchAd:(NSString *)placement
  49. {
  50. // Placement may be SPLASH_AD as noted above
  51. [FlurryAds fetchAdForSpace:placement view:self.view.frame size:FULLSCREEN];
  52. }
  53. // Show whenever delegate is invoked
  54. - (void) spaceDidReceiveAd:(NSString *)adSpace {
  55. // Received Ad
  56. [FlurryAds displayAdForSpace:adSpace];
  57. }
  58. // Alternatively, try to display at a certain point in the app
  59. - (void) levelComplete {
  60. if([FlurryAds adReadyForSpace:adSpace]) {
  61. [FlurryAds displayAdForSpace:adSpace];
  62. }
  63. }
  64. * @endcode
  65. *
  66. * @param space The placement of an ad in your app, where placement may
  67. * be splash screen for SPLASH_AD.
  68. * @param frame The frame of the view that will be used for the ad container.
  69. * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
  70. */
  71. +(void) fetchAdForSpace:(NSString*)space frame:(CGRect)frame size:(FlurryAdSize)size;
  72. /*!
  73. * @brief Returns if an ad is currently ready to display for a given @c space.
  74. * @since 4.1.0
  75. *
  76. * This method will verify if there is an ad is currently available for this
  77. * user. If an ad is not available, you may call #fetchAdForSpace:view:size: to load a new ad.
  78. *
  79. * @note If this method returns YES, an ad will be available when you attempt to display an ad. However, it is still advisable to listen to the delegate FlurryAdsDelegate#spaceDidFailToRender:. \n
  80. The @c space simply represents the placement of the ad in your app and should be
  81. * unique for each placement. For example, if you are displaying a full screen ad on your
  82. * splash screen and after level completeion, you may have the following spaces
  83. * @c @"SPLASH_AD" and @c @"LEVEL_AD".
  84. *
  85. * @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n
  86. #displayAdForSpace: for details on displaying the available ad.
  87. *
  88. * @code
  89. * - (void)showButtonForAd:(NSString *)placement
  90. {
  91. // Placement may be SPLASH_AD as noted above
  92. if([FlurryAds adReadyForSpace:placement])
  93. {
  94. // Show button that ads are available.
  95. }
  96. }
  97. * @endcode
  98. *
  99. * @param space The placement of an ad in your app, where placement may
  100. * be splash screen for SPLASH_AD.
  101. *
  102. * @return YES/NO to indicate if an ad is ready to be displayed.
  103. */
  104. +(BOOL) adReadyForSpace:(NSString*)space;
  105. /*!
  106. * @brief Display an ad for the given @c space.
  107. * @since 4.1.0
  108. *
  109. * This method will display an ad if one is ready for display on the device.
  110. *
  111. * @note The @c space simply represents the placement of the ad in your app and should be
  112. * unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your
  113. * splash screen and after level completeion, you may have the following spaces
  114. * @c @"SPLASH_AD" and @c @"LEVEL_AD".
  115. *
  116. * @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n
  117. #adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n
  118. * #removeAdFromSpace: for details on manually removing an ad from a view. \n
  119. * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
  120. * FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request.
  121. *
  122. * @code
  123. * - (void)showFullscreenAd:(NSString *)placement
  124. {
  125. // Placement may be SPLASH_AD as noted above
  126. if([FlurryAds adReadyForSpace:placement])
  127. {
  128. [FlurryAds displayAdForSpace:placement onView:view];
  129. }
  130. }
  131. * @endcode
  132. *
  133. * @param space The placement of an ad in your app, where placement may
  134. * @param view The view to place the ad. The view frame should be identical to the view frame passed in #fetchAdForSpace:frame:size. Note view is not used for interstitials.
  135. * be splash screen for SPLASH_AD.
  136. */
  137. + (void)displayAdForSpace:(NSString*)space onView:(UIView *)view;
  138. /*!
  139. * @brief Display an ad for the given interstitial @c space.
  140. * @since 4.2.2
  141. *
  142. * This method will display an interstitial ad if one is ready for display on the device for specified UIViewController instance
  143. *
  144. * @note The @c space simply represents the placement of the ad in your app and should be
  145. * unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your
  146. * splash screen and after level completeion, you may have the following spaces
  147. * @c @"SPLASH_AD" and @c @"LEVEL_AD".
  148. *
  149. * @see #fetchAdForSpace:view:size: for details on retrieving an ad.\n
  150. #adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n
  151. * #removeAdFromSpace: for details on manually removing an ad from a view. \n
  152. * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
  153. * FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request.
  154. *
  155. * @code
  156. * in UIViewController based class:
  157. * - (void)showFullscreenAd:(NSString *)placement
  158. {
  159. // Placement may be SPLASH_AD as noted above
  160. if([FlurryAds adReadyForSpace:placement])
  161. {
  162. [FlurryAds displayAdForSpace:placement modallyForViewController:self];
  163. }
  164. }
  165. * @endcode
  166. *
  167. * @param space The placement of an ad in your app, where placement may
  168. * @param viewController The viewController to show the fullscreen ad modally.
  169. * Note this method should not be used for banners.
  170. */
  171. + (void)displayAdForSpace:(NSString*)space modallyForViewController:(UIViewController *)viewController;
  172. /*!
  173. * @brief [Deprecated] Check if an ad is available for the given @c space.
  174. * @since 4.0.0
  175. * @deprecated
  176. *
  177. * [Deprecated] This method will verify with the Flurry server if an ad is currently available for this
  178. * user. If an ad is not available, we recommend not providing the user the
  179. * option to view. For example, you may have a button that reads "See other great apps!".
  180. * That button should only be displayed if this method returns YES.
  181. *
  182. * @note This method has been deprecated.
  183. *
  184. * @see #fetchAdForSpace:view:size: for replacement method.\n
  185. *
  186. * @param space The placement of an ad in your app, where placement may
  187. * be splash screen for SPLASH_AD.
  188. * @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container, but the size of the view may still be used for determining what types of ads will fit in this space.
  189. * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
  190. * @param timeout The maximum amount of time to wait for the server to return a result. Set this to 0 to check the cache and return immediately.
  191. *
  192. * @return YES/NO to indicate if an ad is available.
  193. */
  194. +(BOOL) isAdAvailableForSpace:(NSString*)space view:(UIView *)view size:(FlurryAdSize)size timeout:(int64_t)timeout __attribute__ ((deprecated));
  195. /*!
  196. * @brief [Deprecated] Display an ad for the given @c space.
  197. * @since 4.0.0
  198. * @deprecated
  199. *
  200. * [Deprecated] This method will display an ad if one is available from the Flurry server for this
  201. * user.
  202. *
  203. * @note This method has been deprecated.
  204. *
  205. * @see #fetchAndDisplayAdForSpace:view:size:timeout: for replacement method
  206. *
  207. * @param space The placement of an ad in your app, where placement may
  208. * be splash screen for SPLASH_AD.
  209. * @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container, but the size of the view may still be used for determining what types of ads will fit in this space.
  210. * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
  211. * @param timeout The maximum amount of time to wait for the server to return a valid ad. Set this to 0 to display an ad in the background (e.g. - for showing banners).
  212. *
  213. * @return YES/NO to indicate if an ad is available.
  214. */
  215. + (BOOL)showAdForSpace:(NSString*)space view:(UIView *)viewContainer size:(FlurryAdSize)size timeout:(int64_t)timeout __attribute__ ((deprecated));
  216. /*!
  217. * @brief Fetch and Display an ad for the given @c space.
  218. * @since 4.0.0
  219. *
  220. * This method will display an ad if one is available from the Flurry server for this
  221. * user.
  222. *
  223. * @note If this method returns YES, an ad is available for the space within @c timeout. \n
  224. * This is a blocking method that allows you to change the user experience based on availability of an ad. If you would like to display an ad asynchronously, just set timeout to 0. This is useful in the case of banners for instance where the user should not wait for its display. If you are loading async with timeout set to 0, ignore the return value of this method and rely exclusively on the relevant delegate methods listed below\n
  225. * The @c space simply represents the placement of the ad in your app and should be
  226. * unique for each placement. Only one ad will show at a time for any given ad space. For example, if you are displaying a full screen ad on your
  227. * splash screen and after level completeion, you may have the following spaces
  228. * @c @"SPLASH_AD" and @c @"LEVEL_AD".
  229. *
  230. * @see #adReadyForSpace: for details on verifying is an ad is ready to be displayed. \n
  231. * #removeAdFromSpace: for details on manually removing an ad from a view. \n
  232. * FlurryAdDelegate#spaceDidReceiveAd: for details on the notification of ads being received.
  233. * FlurryAdDelegate#spaceDidFailToReceiveAd:error: for details on notification of failure to receive ads from this request.
  234. * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
  235. * FlurryAdDelegate#spaceDidFailToRender:error: for details on notification of error in rendering an ad for this request.
  236. *
  237. * @code
  238. * - (void)showFullscreenAd:(NSString *)placement
  239. {
  240. // Placement may be SPLASH_AD as noted above
  241. [FlurryAds fetchAndDisplayAdForSpace:placement view:self.view size:FULLSCREEN timeout:3000];
  242. }
  243. - (void)viewWillAppear:(BOOL)animated
  244. {
  245. // Show a banner whenever this view appears
  246. // Display banner ad completely asyncrhonously by providing timeout == 0
  247. [FlurryAds fetchAndDisplayAdForSpace:@"VIEW_XYZ_BANNER_AD" view:self.view size:BANNER_BOTTOM timeout:0];
  248. }
  249. * @endcode
  250. *
  251. * @param space The placement of an ad in your app, where placement may
  252. * be splash screen for SPLASH_AD.
  253. * @param view The UIView in your app that the ad will be placed as a subview. Note: for fullscreen ads, this view is not used as a container, but the size of the view may still be used for determining what types of ads will fit in this space.
  254. * @param size The default size of an ad space. This can be overriden on the server. See @c FlurryAdSize in the FlurryAds.h file for allowable values.
  255. */
  256. + (void)fetchAndDisplayAdForSpace:(NSString*)space view:(UIView *)viewContainer size:(FlurryAdSize)size;
  257. /*!
  258. * @brief Removes an ad for the given @c space.
  259. * @since 4.0.0
  260. *
  261. * This method will remove an ad if one is currently displaying.
  262. *
  263. * @note The @c space simply represents the placement of the ad in your app and should be
  264. * unique for each placement. Only one ad will show at a time for any given ad space.
  265. *
  266. * @see #isAdAvailableForSpace:view:size:timeout: for details on displaying an available ad. \n
  267. * #removeAdFromSpace: for details on manually removing an ad from a view. \n
  268. * FlurryAdDelegate#spaceShouldDisplay:forType: for details on controlling whether an ad will display immediately before it is set to be rendered to the user.
  269. *
  270. * @code
  271. * - (void)viewDidUnload
  272. {
  273. // Remove a banner whenever this view dissapears
  274. [FlurryAds removeAdFromSpace:@"VIEW_XYZ_BANNER_AD"];
  275. }
  276. * @endcode
  277. *
  278. * @param space The placement of an ad in your app, where placement may
  279. * be splash screen for SPLASH_AD.
  280. */
  281. + (void) removeAdFromSpace:(NSString*)space;
  282. /*!
  283. * @brief Initializes the ad serving system.
  284. * @since 4.0
  285. *
  286. * This method initializes the ad serving system and can be used to pre-cache ads from the server (this is done when ad spaces are configured on the server).
  287. *
  288. * @note This method must be called sometime after Flurry#startSession:.
  289. *
  290. * @code
  291. * - (void)applicationDidFinishLaunching:(UIApplication *)application
  292. {
  293. // Optional Flurry startup methods
  294. [Flurry startSession:@"YOUR_API_KEY"];
  295. [FlurryAds setAdDelegate:self];
  296. [FlurryAds initialize:myWindow.rootViewController];
  297. // ....
  298. }
  299. * @endcode
  300. *
  301. * @param rvc The primary root view controller of your app.
  302. *
  303. */
  304. + (void) initialize: (UIViewController *)rvc;
  305. /*!
  306. * @brief Sets the object to receive various delegate methods.
  307. * @since 4.0
  308. *
  309. * This method allows you to register an object that will receive
  310. * notifications at different phases of ad serving.
  311. *
  312. * @see FlurryAdDelegate.h for details on delegates available.
  313. *
  314. * @code
  315. * - (void)applicationDidFinishLaunching:(UIApplication *)application
  316. {
  317. // Optional Flurry startup methods
  318. [Flurry startSession:@"YOUR_API_KEY"];
  319. [FlurryAds setAdDelegate:self];
  320. // ....
  321. }
  322. * @endcode
  323. *
  324. * @param delegate The object to receive notifications of various ad actions.
  325. *
  326. */
  327. + (void)setAdDelegate:(id)delegate;
  328. /*!
  329. * @brief Informs server to send test ads.
  330. * @since 4.0
  331. *
  332. * This method allows you to request test ads from the server. These ads do not generate revenue so it is CRITICAL this call is removed prior to app submission.
  333. *
  334. *
  335. * @code
  336. * - (void)applicationDidFinishLaunching:(UIApplication *)application
  337. {
  338. // Optional Flurry startup methods
  339. [Flurry startSession:@"YOUR_API_KEY"];
  340. [FlurryAds enableTestAds:YES];
  341. // ....
  342. }
  343. * @endcode
  344. *
  345. * @param enable YES to receive test ads to the device. Not including this method is equivalent to passing NO.
  346. *
  347. */
  348. + (void)enableTestAds:(BOOL)enable;
  349. /*!
  350. * @brief Sets a dictionary of key/value pairs, which will be transmitted to Flurry servers when a user clicks on an ad.
  351. * @since 4.0.0
  352. *
  353. * UserCookies allow the developer to specify information on a user executing an ad action. There is one UserCookie object, and on each ad click that UserCookie is transmitted to the Flurry servers. The UserCookie key/value pairs will be transmitted back to the developer via the app callback if one is set. This is useful for rewarded inventory, to identify which of your users should be rewarded when a reward callback is sent.
  354. *
  355. * @note Calling this method with a nil or empty dictionary has no effect. Calling this method a second time with a valid dictionary will replace the previous entries. To clear previously set userCookies, you must call #clearUserCookies.
  356. * @see #clearUserCookies for details on removing user cookies set through this method.
  357. *
  358. * @code
  359. * - (void)applicationDidFinishLaunching:(UIApplication *)application
  360. {
  361. // Optional Flurry startup methods
  362. [Flurry startSession:@"YOUR_API_KEY"];
  363. NSDictionary *cookies =
  364. [NSDictionary dictionaryWithObjectsAndKeys:@"xyz123", // Parameter Value
  365. @"UserCharacterId", // Parameter Name
  366. nil];
  367. [FlurryAds setUserCookies:cookies];
  368. // ....
  369. }
  370. * @endcode
  371. *
  372. * @param userCookies The information about the user executing ad actions. Note: do not transmit personally identifiable information in the user cookies.
  373. */
  374. + (void) setUserCookies:(NSDictionary *) userCookies;
  375. /*!
  376. * @brief Removes a previously set dictionary of key/value pairs.
  377. * @since 4.0.0
  378. *
  379. * This method removes information from the one UserCookie object.
  380. *
  381. * @see #setUserCookies: for details on setting user cookies.
  382. *
  383. */
  384. + (void) clearUserCookies;
  385. /*!
  386. * @brief Sets a dictionary of key/value pairs, which will be transmitted to Flurry servers when an ad is requested.
  387. * @since 4.0.0
  388. *
  389. * Keywords allow the developer to specify information on a user executing an ad action for the purposes of targeting. There is one keywords object that is transmitted to the Flurry servers on each ad request. If corresponding keywords are matched on the ad server, a subset of targeted ads will be delivered. This allows partners to supply information they track internally, which is not available to Flurry's targeting system.
  390. *
  391. * @note Calling this method with a nil or empty dictionary has no effect. Calling this method a second time with a valid dictionary will replace the previous entries. To clear previously set keywords, you must call #clearKeywords.
  392. * @see #clearKeywords for details on removing keywords set through this method.
  393. *
  394. * @code
  395. * - (void)applicationDidFinishLaunching:(UIApplication *)application
  396. {
  397. // Optional Flurry startup methods
  398. [Flurry startSession:@"YOUR_API_KEY"];
  399. // Specify that user loves vacations
  400. NSDictionary *keywords =
  401. [NSDictionary dictionaryWithObjectsAndKeys:@"vacation", // Parameter Value
  402. @"UserPreference", // Parameter Name
  403. nil];
  404. [FlurryAds setKeywords:keywords];
  405. // ....
  406. }
  407. * @endcode
  408. *
  409. * @param keywords The information about the user to be used in targeting an ad. Note: do not transmit personally identifiable information in keywords.
  410. */
  411. + (void) setKeywordsForTargeting:(NSDictionary*) keywords;
  412. /*!
  413. * @brief Removes a previously set dictionary of key/value pairs.
  414. * @since 4.0.0
  415. *
  416. * This method removes information from the one keywords object.
  417. *
  418. * @see #setKeywords: for details on setting keywords.
  419. *
  420. */
  421. + (void) clearKeywords;
  422. /*!
  423. * @brief Method to add a custom ad network to be served through the standard Flurry ad system.
  424. * @since 4.0.0
  425. *
  426. * This method adds a network with the necessary publisher supplied properties to the Flurry sdk.
  427. *
  428. * @see @c FlurryCustomAdNetwork and @c FlurryCustomAdNetworkProperties for details.
  429. *
  430. */
  431. + (void) addCustomAdNetwork:(Class<FlurryCustomAdNetwork>)adNetworkClass withProperties:(id<FlurryCustomAdNetworkProperties>)adNetworkProperties;
  432. @end