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
116 static bool getOptOutAdvertisingID(jobject context);
117#endif
118
126 static bool connect(const char* sdkKey, TJConnectListener* listener = NULL);
127
128
138 static bool connect(const char* sdkKey,const std::map<const char*, const char*>& flags, TJConnectListener* listener = NULL);
139
150
160 static void spendCurrency(int amount, TJSpendCurrencyListener* listener);
161
171 static void awardCurrency(int amount, TJAwardCurrencyListener* listener);
172
181
191 static void trackPurchase(const char* currencyCode, double price);
192
193
209 static void trackPurchase(const char* productId, const char* currencyCode, double price, const char* campaignId);
210
211#if defined(ANDROID)
232 static void trackPurchaseInGooglePlayStore(const char* skuDetails, const char* purchaseData, const char* dataSignature, const char* campaignId);
233#endif
234#if defined(__APPLE__)
251 static void trackPurchaseInAppleAppStore(const char* productId, const char* currencyCode, double price, const char* transactionId, const char* campaignId);
252#endif
253
258 static void startSession();
259
264 static void endSession();
265
275 static void setUserID(const char* userID, TJSetUserIDListener* listener);
276
282 static const char* getUserID();
283
291 static void setCustomParameter(const char* referrer);
292
298 static const char* getCustomParameter();
299
305 static int getUserLevel();
306
313 static void setUserLevel(int userLevel);
314
321 static void setMaxLevel(int maxLevel);
322
328 static int getMaxLevel();
329
335 static void setUserSegment(int userSegment);
336
342 static int getUserSegment();
343
347 static void clearUserTags();
348
355 static void addUserTag(const char* tag);
356
363 static void removeUserTag(const char* tag);
364
373 static void actionComplete(const char* actionID);
374
378 static bool isConnected();
379 };
380
381#if defined(ANDROID)
382 typedef jobject TJActionRequestHandle;
383 typedef jobject TJPlacementHandle;
384 typedef jobject TJPrivacyPolicyHandle;
385#else
386 typedef void* TJActionRequestHandle;
387 typedef void* TJPlacementHandle;
388 typedef void* TJPrivacyPolicyHandle;
389#endif
390
392 public:
393 virtual ~TJConnectListener() {}
394
395 virtual void onConnectSuccess() {}
396 virtual void onConnectFailure(int code, const char* error) {}
397 virtual void onConnectWarning(int code, const char* error) {}
398 };
399
401 public:
402 virtual ~TJAwardCurrencyListener() {}
403
404 virtual void onAwardCurrencyResponse(const char* currencyName, int balance) {}
405 virtual void onAwardCurrencyResponseFailure(const char* error) {}
406 };
407
409 public:
410 virtual ~TJEarnedCurrencyListener() {}
411
412 virtual void onEarnedCurrency(const char* currencyName, int amount) {}
413 };
414
416 public:
418
419 virtual void onGetCurrencyBalanceResponse(const char* currencyName, int balance) {}
420 virtual void onGetCurrencyBalanceResponseFailure(const char* error) {}
421 };
422
424 public:
425 virtual ~TJSpendCurrencyListener() {}
426
427 virtual void onSpendCurrencyResponse(const char* currencyName, int balance) {}
428 virtual void onSpendCurrencyResponseFailure(const char* error) {}
429 };
430
432 public:
434
435 virtual void onSetCurrencyBalanceSuccess() {}
436 virtual void onSetCurrencyBalanceFailure(int code, const char* error) {}
437 };
438
440 public:
442
443 virtual void onSetCurrencyAmountRequiredSuccess() {}
444 virtual void onSetCurrencyAmountRequiredFailure(int code, const char* error) {}
445 };
446
448 public:
449 virtual ~TJSetUserIDListener() {}
450
451 virtual void onSetUserIDSuccess() {}
452 virtual void onSetUserIDFailure(int code, const char* error) {}
453 };
454
456 public:
457 virtual ~TJPlacementListener() {}
458
459 virtual void onRequestSuccess(TJPlacementHandle placementHandle, const char* placementName) {}
460 virtual void onRequestFailure(TJPlacementHandle placementHandle, const char* placementName, int errorCode, const char* errorMessage) {}
461 virtual void onContentReady(TJPlacementHandle placementHandle, const char* placementName) {}
462 virtual void onContentShow(TJPlacementHandle placementHandle, const char* placementName) {}
463 virtual void onContentDismiss(TJPlacementHandle placementHandle, const char* placementName) {}
464 // @deprecated since 14.2.0
465 virtual void onClick(TJPlacementHandle placementHandle, const char* placementName) {}
466 virtual void onPurchaseRequest(TJPlacementHandle placementHandle, const char* placementName, TJActionRequestHandle requestHandle, const char* requestId, const char* requestToken, const char* productId) {}
467 virtual void onRewardRequest(TJPlacementHandle placementHandle, const char* placementName, TJActionRequestHandle requestHandle, const char* requestId, const char* requestToken, const char* itemId, int quantity) {}
468 };
469
471 public:
472 static void completed(TJActionRequestHandle actionRequestHandle);
473 static void cancelled(TJActionRequestHandle actionRequestHandle);
474 };
475
477 public:
478#if defined(ANDROID)
479 static TJPlacementHandle create(jobject activityContext, const char* placementName, TJPlacementListener* listener);
480#endif
481 static TJPlacementHandle create(const char* placementName, TJPlacementListener* listener);
482 static void release(TJPlacementHandle placementHandle);
483 static bool isContentReady(TJPlacementHandle placementHandle);
484 static bool isContentAvailable(TJPlacementHandle placementHandle);
485 static void requestContent(TJPlacementHandle placementHandle);
486 static void showContent(TJPlacementHandle placementHandle);
487 static void setCurrencyBalance(TJPlacementHandle handle, const char* currencyId, int amount, TJSetCurrencyBalanceListener* listener);
488 static void setCurrencyAmountRequired(TJPlacementHandle handle, const char* currencyId, int amount, TJSetCurrencyAmountRequiredListener* listener);
489 static int getCurrencyBalance(TJPlacementHandle handle, const char* currencyId);
490 static int getCurrencyAmountRequired(TJPlacementHandle handle, const char* currencyId);
491 static void setEntryPoint(TJPlacementHandle placementHandle, TJEntryPoint entryPoint);
492 static TJEntryPoint getEntryPoint(TJPlacementHandle placementHandle);
493#if defined(__APPLE__) && defined(__OBJC__)
494 static void showContentWithViewController(TJPlacementHandle placementHandle, UIViewController* viewController);
495#endif
496 static void dismissContent();
497 };
498
499 enum class TJStatusCpp : size_t {
500 TJStatusFalse = 0,
501 TJStatusTrue = 1,
502 TJStatusUnknown = 2
503 };
504
506 public:
512 static TJPrivacyPolicyHandle getPrivacyPolicy();
513
523 static void setSubjectToGDPRStatus(TJPrivacyPolicyHandle handle, TJStatusCpp gdprStatus);
524
532 static void setUserConsentStatus(TJPrivacyPolicyHandle handle, TJStatusCpp userConsentStatus);
533
548 static void setBelowConsentAgeStatus(TJPrivacyPolicyHandle handle, TJStatusCpp belowConsentAgeStatus);
549
559 static void setUSPrivacy(TJPrivacyPolicyHandle handle, const char* privacyValue);
560 };
561
562}
563
564#endif // TapjoyCpp_h
Definition TapjoyCpp.h:470
Definition TapjoyCpp.h:400
Definition TapjoyCpp.h:391
Definition TapjoyCpp.h:408
Definition TapjoyCpp.h:415
Definition TapjoyCpp.h:476
Definition TapjoyCpp.h:455
Definition TapjoyCpp.h:505
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:431
Definition TapjoyCpp.h:447
Definition TapjoyCpp.h:423
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 bool getOptOutAdvertisingID(jobject context)
Returns the currently set opt out advertising_id value.
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.