Tapjoy SDK - C++ API
 
Loading...
Searching...
No Matches
TapjoyCpp.h
Go to the documentation of this file.
1//
2// Copyright (c) 2015 - 2018 Tapjoy, Inc.
3// All rights reserved.
4//
5
11#ifndef TapjoyCpp_h
12#define TapjoyCpp_h
13
14#include <stdint.h>
15#include "jni_common.h"
16#include "TJEntryPoint.h"
17#if defined(ANDROID)
18#include <jni.h>
19#include <map>
20#endif
21#if defined(__APPLE__) && defined(__OBJC__)
22#import <UIKit/UIKit.h>
23#endif
24
25namespace tapjoy {
26
27 class TJConnectListener;
28 class TJGetCurrencyBalanceListener;
29 class TJSpendCurrencyListener;
30 class TJAwardCurrencyListener;
31 class TJEarnedCurrencyListener;
32 class TJPlacementListener;
33 class TJSetUserIDListener;
34
38 class Tapjoy {
39 public:
40
41#if defined(ANDROID) && defined(TAPJOY_STATIC)
48 static jint setJavaVM(JavaVM* vm);
49#endif
50
51#if defined(ANDROID)
52 /*
53 * @brief Set common context for Android
54 * @param context
55 * a context
56 */
57 static void setContext(jobject context);
58#endif
59
63 static const char* getLibraryName();
64
69 static const char* getVersion();
70
76 static void setDebugEnabled(bool enable);
77
78#if defined(ANDROID)
90 static bool connect(jobject context, const char* sdkKey, const std::map<const char*, const char*>& flags, TJConnectListener* listener = NULL);
91
101 static bool connect(jobject context, const char* sdkKey, TJConnectListener* listener = NULL);
102
109 static void optOutAdvertisingID(jobject context, bool optOut);
110#endif
111
119 static bool connect(const char* sdkKey, TJConnectListener* listener = NULL);
120
121
131 static bool connect(const char* sdkKey,const std::map<const char*, const char*>& flags, TJConnectListener* listener = NULL);
132
143
153 static void spendCurrency(int amount, TJSpendCurrencyListener* listener);
154
164 static void awardCurrency(int amount, TJAwardCurrencyListener* listener);
165
174
184 static void trackPurchase(const char* currencyCode, double price);
185
186
202 static void trackPurchase(const char* productId, const char* currencyCode, double price, const char* campaignId);
203
204#if defined(ANDROID)
225 static void trackPurchaseInGooglePlayStore(const char* skuDetails, const char* purchaseData, const char* dataSignature, const char* campaignId);
226#endif
227#if defined(__APPLE__)
244 static void trackPurchaseInAppleAppStore(const char* productId, const char* currencyCode, double price, const char* transactionId, const char* campaignId);
245#endif
246
251 static void startSession();
252
257 static void endSession();
258
268 static void setUserID(const char* userID, TJSetUserIDListener* listener);
269
275 static const char* getUserID();
276
284 static void setCustomParameter(const char* referrer);
285
291 static const char* getCustomParameter();
292
298 static int getUserLevel();
299
306 static void setUserLevel(int userLevel);
307
314 static void setMaxLevel(int maxLevel);
315
321 static int getMaxLevel();
322
328 static void setUserSegment(int userSegment);
329
335 static int getUserSegment();
336
340 static void clearUserTags();
341
348 static void addUserTag(const char* tag);
349
356 static void removeUserTag(const char* tag);
357
366 static void actionComplete(const char* actionID);
367
371 static bool isConnected();
372 };
373
374#if defined(ANDROID)
375 typedef jobject TJActionRequestHandle;
376 typedef jobject TJPlacementHandle;
377 typedef jobject TJPrivacyPolicyHandle;
378#else
379 typedef void* TJActionRequestHandle;
380 typedef void* TJPlacementHandle;
381 typedef void* TJPrivacyPolicyHandle;
382#endif
383
385 public:
386 virtual ~TJConnectListener() {}
387
388 virtual void onConnectSuccess() {}
389 virtual void onConnectFailure(int code, const char* error) {}
390 virtual void onConnectWarning(int code, const char* error) {}
391 };
392
394 public:
395 virtual ~TJAwardCurrencyListener() {}
396
397 virtual void onAwardCurrencyResponse(const char* currencyName, int balance) {}
398 virtual void onAwardCurrencyResponseFailure(const char* error) {}
399 };
400
402 public:
403 virtual ~TJEarnedCurrencyListener() {}
404
405 virtual void onEarnedCurrency(const char* currencyName, int amount) {}
406 };
407
409 public:
411
412 virtual void onGetCurrencyBalanceResponse(const char* currencyName, int balance) {}
413 virtual void onGetCurrencyBalanceResponseFailure(const char* error) {}
414 };
415
417 public:
418 virtual ~TJSpendCurrencyListener() {}
419
420 virtual void onSpendCurrencyResponse(const char* currencyName, int balance) {}
421 virtual void onSpendCurrencyResponseFailure(const char* error) {}
422 };
423
425 public:
427
428 virtual void onSetCurrencyBalanceSuccess() {}
429 virtual void onSetCurrencyBalanceFailure(int code, const char* error) {}
430 };
431
433 public:
435
436 virtual void onSetCurrencyAmountRequiredSuccess() {}
437 virtual void onSetCurrencyAmountRequiredFailure(int code, const char* error) {}
438 };
439
441 public:
442 virtual ~TJSetUserIDListener() {}
443
444 virtual void onSetUserIDSuccess() {}
445 virtual void onSetUserIDFailure(int code, const char* error) {}
446 };
447
449 public:
450 virtual ~TJPlacementListener() {}
451
452 virtual void onRequestSuccess(TJPlacementHandle placementHandle, const char* placementName) {}
453 virtual void onRequestFailure(TJPlacementHandle placementHandle, const char* placementName, int errorCode, const char* errorMessage) {}
454 virtual void onContentReady(TJPlacementHandle placementHandle, const char* placementName) {}
455 virtual void onContentShow(TJPlacementHandle placementHandle, const char* placementName) {}
456 virtual void onContentDismiss(TJPlacementHandle placementHandle, const char* placementName) {}
457 // @deprecated since 14.2.0
458 virtual void onClick(TJPlacementHandle placementHandle, const char* placementName) {}
459 virtual void onPurchaseRequest(TJPlacementHandle placementHandle, const char* placementName, TJActionRequestHandle requestHandle, const char* requestId, const char* requestToken, const char* productId) {}
460 virtual void onRewardRequest(TJPlacementHandle placementHandle, const char* placementName, TJActionRequestHandle requestHandle, const char* requestId, const char* requestToken, const char* itemId, int quantity) {}
461 };
462
464 public:
465 static void completed(TJActionRequestHandle actionRequestHandle);
466 static void cancelled(TJActionRequestHandle actionRequestHandle);
467 };
468
470 public:
471#if defined(ANDROID)
472 static TJPlacementHandle create(jobject activityContext, const char* placementName, TJPlacementListener* listener);
473#endif
474 static TJPlacementHandle create(const char* placementName, TJPlacementListener* listener);
475 static void release(TJPlacementHandle placementHandle);
476 static bool isContentReady(TJPlacementHandle placementHandle);
477 static bool isContentAvailable(TJPlacementHandle placementHandle);
478 static void requestContent(TJPlacementHandle placementHandle);
479 static void showContent(TJPlacementHandle placementHandle);
480 static void setCurrencyBalance(TJPlacementHandle handle, const char* currencyId, int amount, TJSetCurrencyBalanceListener* listener);
481 static void setCurrencyAmountRequired(TJPlacementHandle handle, const char* currencyId, int amount, TJSetCurrencyAmountRequiredListener* listener);
482 static int getCurrencyBalance(TJPlacementHandle handle, const char* currencyId);
483 static int getCurrencyAmountRequired(TJPlacementHandle handle, const char* currencyId);
484 static void setEntryPoint(TJPlacementHandle placementHandle, TJEntryPoint entryPoint);
485 static TJEntryPoint getEntryPoint(TJPlacementHandle placementHandle);
486#if defined(__APPLE__) && defined(__OBJC__)
487 static void showContentWithViewController(TJPlacementHandle placementHandle, UIViewController* viewController);
488#endif
489 static void dismissContent();
490 };
491
492 enum class TJStatusCpp : size_t {
493 TJStatusFalse = 0,
494 TJStatusTrue = 1,
495 TJStatusUnknown = 2
496 };
497
499 public:
505 static TJPrivacyPolicyHandle getPrivacyPolicy();
506
516 static void setSubjectToGDPRStatus(TJPrivacyPolicyHandle handle, TJStatusCpp gdprStatus);
517
525 static void setUserConsentStatus(TJPrivacyPolicyHandle handle, TJStatusCpp userConsentStatus);
526
541 static void setBelowConsentAgeStatus(TJPrivacyPolicyHandle handle, TJStatusCpp belowConsentAgeStatus);
542
552 static void setUSPrivacy(TJPrivacyPolicyHandle handle, const char* privacyValue);
553 };
554
555}
556
557#endif // TapjoyCpp_h
Definition TapjoyCpp.h:463
Definition TapjoyCpp.h:393
Definition TapjoyCpp.h:384
Definition TapjoyCpp.h:401
Definition TapjoyCpp.h:408
Definition TapjoyCpp.h:469
Definition TapjoyCpp.h:448
Definition TapjoyCpp.h:498
static void setSubjectToGDPRStatus(TJPrivacyPolicyHandle handle, TJStatusCpp gdprStatus)
This can be used by the integrating App to indicate if the user falls in any of the GDPR applicable c...
static void setUSPrivacy(TJPrivacyPolicyHandle handle, const char *privacyValue)
This is used for sending US Privacy value to behavioral advertising such as in the context of GDPR Th...
static TJPrivacyPolicyHandle getPrivacyPolicy()
Returns the TJPrivacyPolicy instance for calling methods to set GDPR, User's consent,...
static void setUserConsentStatus(TJPrivacyPolicyHandle handle, TJStatusCpp userConsentStatus)
This is used for sending User's consent to behavioral advertising such as in the context of GDPR The ...
static void setBelowConsentAgeStatus(TJPrivacyPolicyHandle handle, TJStatusCpp belowConsentAgeStatus)
In the US, the Children’s Online Privacy Protection Act (COPPA) imposes certain requirements on opera...
Definition TapjoyCpp.h:424
Definition TapjoyCpp.h:440
Definition TapjoyCpp.h:416
C++ API class of the Tapjoy SDK.
Definition TapjoyCpp.h:38
static void getCurrencyBalance(TJGetCurrencyBalanceListener *listener)
Gets the virtual currency data from the server for this device.
static void trackPurchase(const char *currencyCode, double price)
Tracks a purchase.
static const char * getLibraryName()
Returns the name of the library linked.
static const char * getUserID()
Gets the id of the user.
static void actionComplete(const char *actionID)
Informs the Tapjoy server that the specified Pay-Per-Action was completed. Should be called whenever ...
static bool connect(jobject context, const char *sdkKey, TJConnectListener *listener=NULL)
Connects to the Tapjoy Server.
static void clearUserTags()
Removes all tags from the user.
static void trackPurchaseInGooglePlayStore(const char *skuDetails, const char *purchaseData, const char *dataSignature, const char *campaignId)
Tracks a purchase with JSON data from the Google Play store. Also performs In-app Billing validation ...
static int getUserLevel()
Gets the level of the user.
static void startSession()
Manual session tracking.
static void spendCurrency(int amount, TJSpendCurrencyListener *listener)
Spends virtual currency.
static void setCustomParameter(const char *referrer)
Assign a custom parameter associated with any following placement requests that contains an ad type.
static void setUserLevel(int userLevel)
Sets the level of the user.
static const char * getCustomParameter()
Returns the currently set custom parameter.
static bool isConnected()
Helper function to check if SDK is initialized.
static bool connect(jobject context, const char *sdkKey, const std::map< const char *, const char * > &flags, TJConnectListener *listener=NULL)
Connects to the Tapjoy Server.
static void removeUserTag(const char *tag)
Removes the given tag from the user if it is present.
static void addUserTag(const char *tag)
Adds the given tag to the user if it is not already present.
static void setEarnedCurrencyListener(TJEarnedCurrencyListener *listener)
Sets the listener which gets informed whenever virtual currency is earned.
static void setUserID(const char *userID, TJSetUserIDListener *listener)
Assigns a user ID for this user/device.
static void setUserSegment(int userSegment)
Sets the segment of the user.
static int getMaxLevel()
Gets the maximum level of the user.
static const char * getVersion()
Returns the version name of the SDK.
static void setDebugEnabled(bool enable)
Enables the debug mode of the SDK.
static void awardCurrency(int amount, TJAwardCurrencyListener *listener)
Awards virtual currency.
static void trackPurchase(const char *productId, const char *currencyCode, double price, const char *campaignId)
Tracks a purchase.
static void optOutAdvertisingID(jobject context, bool optOut)
This is to opt out passing advertising_id param in the subsequent network requests.
static void setMaxLevel(int maxLevel)
Sets the maximum level of the user.
static void endSession()
Manual session tracking.
static bool connect(const char *sdkKey, const std::map< const char *, const char * > &flags, TJConnectListener *listener=NULL)
Connects to the Tapjoy Server.
static bool connect(const char *sdkKey, TJConnectListener *listener=NULL)
Connects to the Tapjoy Server.
static int getUserSegment()
Gets the segment of the user.