Tapjoy SDK - C++ API
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 
16 #if defined(ANDROID)
17 #include <jni.h>
18 #endif
19 #if defined(__APPLE__) && defined(__OBJC__)
20 #import <UIKit/UIKit.h>
21 #endif
22 
23 namespace tapjoy {
24 
25  class TJConnectListener;
26  class TJGetCurrencyBalanceListener;
27  class TJSpendCurrencyListener;
28  class TJAwardCurrencyListener;
29  class TJEarnedCurrencyListener;
30  class TJVideoListener;
31  class TJPlacementListener;
32 
36  class Tapjoy {
37  public:
38 
39 #if defined(ANDROID) && defined(TAPJOY_STATIC)
40 
46  static jint setJavaVM(JavaVM* vm);
47 #endif
48 
49 #if defined(ANDROID)
50  /*
51  * @brief Set common context for Android
52  * @param context
53  * a context
54  */
55  static void setContext(jobject context);
56 #endif
57 
61  static const char* getLibraryName();
62 
67  static const char* getVersion();
68 
74  static void setDebugEnabled(bool enable);
75 
76 
77 #if defined(ANDROID)
78 
87  static bool connect(jobject context, const char* sdkKey, TJConnectListener* listener = NULL);
88 #endif
89 
97  static bool connect(const char* sdkKey, TJConnectListener* listener = NULL);
98 
108  static void getCurrencyBalance(TJGetCurrencyBalanceListener* listener);
109 
119  static void spendCurrency(int amount, TJSpendCurrencyListener* listener);
120 
130  static void awardCurrency(int amount, TJAwardCurrencyListener* listener);
131 
140 
149  static void setCurrencyMultiplier(float multiplier);
150 
157  static float getCurrencyMultiplier();
158 
173  static void trackPurchase(const char* productId, const char* currencyCode, double price, const char* campaignId);
174 
175 #if defined(ANDROID)
176 
195  static void trackPurchaseInGooglePlayStore(const char* skuDetails, const char* purchaseData, const char* dataSignature, const char* campaignId);
196 #endif
197 #if defined(__APPLE__)
198 
213  static void trackPurchaseInAppleAppStore(const char* productId, const char* currencyCode, double price, const char* transactionId, const char* campaignId);
214 #endif
215 
219  static void trackEvent(const char* name);
220 
229  static void trackEvent(const char* name, int64_t value);
230 
234  static void trackEvent(const char* category, const char* name, int64_t value);
235 
239  static void trackEvent(const char* category, const char* name, const char* parameter1, const char* parameter2);
240 
245  static void trackEvent(const char* category, const char* name, const char* parameter1, const char* parameter2, int64_t value);
246 
251  static void trackEvent(const char* category, const char* name, const char* parameter1, const char* parameter2, const char* valueName, int64_t value);
252 
257  static void trackEvent(const char* category, const char* name, const char* parameter1, const char* parameter2, const char* value1Name, int64_t value1, const char* value2Name, int64_t value2);
258 
259 
260  static void trackEvent(const char* category, const char* name, const char* parameter1, const char* parameter2, const char* value1Name, int64_t value1, const char* value2Name, int64_t value2, const char* value3Name, int64_t value3);
261 
266  static void startSession();
267 
272  static void endSession();
273 
283  static void setUserID(const char* userID);
284 
285 #ifndef DOXYGEN_SHOULD_SKIP_THIS
286 
293  static void setCustomParameter(const char* referrer);
294 
300  static const char* getCustomParameter();
301 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
302 
309  static void setUserLevel(int userLevel);
310 
317  static void setUserFriendCount(int friendCount);
318 
325  static void setAppDataVersion(const char* dataVersion);
326 
335  static void setUserCohortVariable(int variableIndex, const char* value);
336 
340  static void clearUserTags();
341 
348  static void addUserTag(const char* tag);
349 
356  static void removeUserTag(const char* tag);
357 
365  static void setVideoListener(TJVideoListener* listener);
366 
374  static void actionComplete(const char* actionID);
375 
386  static void subjectToGDPR(bool gdprApplicable);
387 
395  static void setUserConsent(const char* value);
396 
410  static void belowConsentAge(bool isBelowConsentAge);
411 
412 #if defined(ANDROID)
413 
416  static bool isPushNotificationDisabled();
417 
423  static void setPushNotificationDisabled(bool disabled);
424 
433  static void setDeviceToken(const char* deviceToken);
434 
442  static void setReceiveRemoteNotification(jobject context,jobject remoteMessage);
443 
451  static void activateInstallReferrerClient(jobject context);
452 
460  static void setInstallReferrer(jobject context, const char* referrer);
461 
462 #endif
463 
467  static bool isConnected();
468  };
469 
470 #if defined(ANDROID)
471  typedef jobject TJActionRequestHandle;
472  typedef jobject TJPlacementHandle;
473  typedef jobject TJPrivacyPolicyHandle;
474 #else
475  typedef void* TJActionRequestHandle;
476  typedef void* TJPlacementHandle;
477  typedef void* TJPrivacyPolicyHandle;
478 #endif
479 
481  public:
482  virtual ~TJConnectListener() {}
483 
484  virtual void onConnectSuccess() {}
485  virtual void onConnectFailure() {}
486  };
487 
489  public:
490  virtual ~TJAwardCurrencyListener() {}
491 
492  virtual void onAwardCurrencyResponse(const char* currencyName, int balance) {}
493  virtual void onAwardCurrencyResponseFailure(const char* error) {}
494  };
495 
497  public:
498  virtual ~TJEarnedCurrencyListener() {}
499 
500  virtual void onEarnedCurrency(const char* currencyName, int amount) {}
501  };
502 
504  public:
505  virtual ~TJGetCurrencyBalanceListener() {}
506 
507  virtual void onGetCurrencyBalanceResponse(const char* currencyName, int balance) {}
508  virtual void onGetCurrencyBalanceResponseFailure(const char* error) {}
509  };
510 
512  public:
513  virtual ~TJSpendCurrencyListener() {}
514 
515  virtual void onSpendCurrencyResponse(const char* currencyName, int balance) {}
516  virtual void onSpendCurrencyResponseFailure(const char* error) {}
517  };
518 
520  public:
521  virtual ~TJVideoListener() {}
522 
523  virtual void onVideoStart() {}
524  virtual void onVideoClose() {}
525  virtual void onVideoError(int statusCode) {}
526  virtual void onVideoComplete() {}
527  };
528 
530  public:
531  virtual ~TJPlacementListener() {}
532 
533  virtual void onRequestSuccess(TJPlacementHandle placementHandle, const char* placementName) {}
534  virtual void onRequestFailure(TJPlacementHandle placementHandle, const char* placementName, int errorCode, const char* errorMessage) {}
535  virtual void onContentReady(TJPlacementHandle placementHandle, const char* placementName) {}
536  virtual void onContentShow(TJPlacementHandle placementHandle, const char* placementName) {}
537  virtual void onContentDismiss(TJPlacementHandle placementHandle, const char* placementName) {}
538  virtual void onClick(TJPlacementHandle placementHandle, const char* placementName) {}
539  virtual void onPurchaseRequest(TJPlacementHandle placementHandle, const char* placementName, TJActionRequestHandle requestHandle, const char* requestId, const char* requestToken, const char* productId) {}
540  virtual void onRewardRequest(TJPlacementHandle placementHandle, const char* placementName, TJActionRequestHandle requestHandle, const char* requestId, const char* requestToken, const char* itemId, int quantity) {}
541  };
542 
544  public:
545  static void completed(TJActionRequestHandle actionRequestHandle);
546  static void cancelled(TJActionRequestHandle actionRequestHandle);
547  };
548 
549  class TJPlacement {
550  public:
551 #if defined(ANDROID)
552  static TJPlacementHandle create(jobject activityContext, const char* placementName, TJPlacementListener* listener);
553 #endif
554  static TJPlacementHandle create(const char* placementName, TJPlacementListener* listener);
555  static void release(TJPlacementHandle placementHandle);
556  static bool isContentReady(TJPlacementHandle placementHandle);
557  static bool isContentAvailable(TJPlacementHandle placementHandle);
558  static void requestContent(TJPlacementHandle placementHandle);
559  static void showContent(TJPlacementHandle placementHandle);
560 #if defined(__APPLE__) && defined(__OBJC__)
561  static void showContentWithViewController(TJPlacementHandle placementHandle, UIViewController* viewController);
562 #endif
563  static void dismissContent();
564  };
565 
567  public:
573  static TJPrivacyPolicyHandle getPrivacyPolicy();
574 
584  static void setSubjectToGDPR(TJPrivacyPolicyHandle handle, bool gdprApplicable);
585 
595  static void setUserConsent(TJPrivacyPolicyHandle handle, const char* consent);
596 
610  static void setBelowConsentAge(TJPrivacyPolicyHandle handle, bool isBelowConsentAge);
611 
621  static void setUSPrivacy(TJPrivacyPolicyHandle handle, const char* privacyValue);
622  };
623 
624 }
625 
626 #endif // TapjoyCpp_h
Definition: TapjoyCpp.h:549
static void removeUserTag(const char *tag)
Removes the given tag from the user if it is present.
static const char * getLibraryName()
Returns the name of the library linked.
static void setUserConsent(TJPrivacyPolicyHandle handle, const char *consent)
Assigns a user ID for this user/device.
static void setBelowConsentAge(TJPrivacyPolicyHandle handle, bool isBelowConsentAge)
In the US, the Children’s Online Privacy Protection Act (COPPA) imposes certain requirements on oper...
static void trackEvent(const char *name)
Tracks an event of the given name without category.
Definition: TapjoyCpp.h:488
static void setAppDataVersion(const char *dataVersion)
Sets the data version of the App or Game.
static void setSubjectToGDPR(TJPrivacyPolicyHandle handle, bool gdprApplicable)
This can be used by the integrating App to indicate if the user falls in any of the GDPR applicable c...
Definition: TapjoyCpp.h:529
static void getCurrencyBalance(TJGetCurrencyBalanceListener *listener)
Gets the virtual currency data from the server for this device.
static void setUserCohortVariable(int variableIndex, const char *value)
Sets a variable of user for the cohort analysis.
static void startSession()
Manual session tracking.
static void setUserID(const char *userID)
Assigns a user ID for this user/device.
Definition: TapjoyCpp.h:566
static bool isConnected()
Helper function to check if SDK is initialized.
static const char * getVersion()
Returns the version name of the SDK.
Definition: TapjoyCpp.h:519
Definition: TapjoyCpp.h:23
static void setDebugEnabled(bool enable)
Enables the debug mode of the SDK.
Definition: TapjoyCpp.h:543
static void spendCurrency(int amount, TJSpendCurrencyListener *listener)
Spends virtual currency.
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 void addUserTag(const char *tag)
Adds the given tag to the user if it is not already present.
static bool connect(const char *sdkKey, TJConnectListener *listener=NULL)
Connects to the Tapjoy Server.
static float getCurrencyMultiplier()
Gets the multiplier for the virtual currency display.
Definition: TapjoyCpp.h:496
static void actionComplete(const char *actionID)
Informs the Tapjoy server that the specified Pay-Per-Action was completed.
static void setVideoListener(TJVideoListener *listener)
Sets the video listener.
static void trackPurchase(const char *productId, const char *currencyCode, double price, const char *campaignId)
Tracks a purchase.
static void awardCurrency(int amount, TJAwardCurrencyListener *listener)
Awards virtual currency.
static TJPrivacyPolicyHandle getPrivacyPolicy()
Returns the TJPrivacyPolicy instance for calling methods to set GDPR, User&#39;s consent, below consent age ,and US Privacy policy flags.
C++ API class of the Tapjoy SDK.
Definition: TapjoyCpp.h:36
static void endSession()
Manual session tracking.
static void setCurrencyMultiplier(float multiplier)
ONLY USE FOR NON-MANAGED (by TAPJOY) CURRENCY.
Definition: TapjoyCpp.h:511
static void setUserConsent(const char *value)
This is used for sending User&#39;s consent to behavioral advertising such as in the context of GDPR The ...
static void clearUserTags()
Removes all tags from the user.
static void setUserFriendCount(int friendCount)
Sets the friends count of the user.
static void setEarnedCurrencyListener(TJEarnedCurrencyListener *listener)
Sets the listener which gets informed whenever virtual currency is earned.
static void belowConsentAge(bool isBelowConsentAge)
In the US, the Children’s Online Privacy Protection Act (COPPA) imposes certain requirements on oper...
static void setUserLevel(int userLevel)
Sets the level of the user.
Definition: TapjoyCpp.h:480
Definition: TapjoyCpp.h:503
static void subjectToGDPR(bool gdprApplicable)
This can be used by the integrating App to indicate if the user falls in any of the GDPR applicable c...