Skip to content

Commit

Permalink
Add userConsent
Browse files Browse the repository at this point in the history
  • Loading branch information
itsSoufianeDev committed Oct 4, 2019
1 parent 3511895 commit bccf3bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/android/StartAppAdsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ public boolean execute(String action, JSONArray args, final CallbackContext call
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
String appId = args.optString(0);
boolean userConsent = args.optBoolean(3);
boolean disableReturnAd = args.optBoolean(1);
boolean disableSplashAd = args.optBoolean(2);

initStartApp(appId, disableReturnAd, disableSplashAd, PUBLIC_CALLBACKS);
initStartApp(appId, disableReturnAd, disableSplashAd, userConsent, PUBLIC_CALLBACKS);
}
});
return true;
Expand Down Expand Up @@ -103,11 +104,11 @@ public void run() {
return false;
}

public void initStartApp(String appID, Boolean disableReturnAd, Boolean disableSplashAd, CallbackContext callbackContext) {
Log.d(TAG, "Initializing StartApp SDK with ID: " + appID + " ReturnAd: " + disableReturnAd + " SplashAd: " + disableSplashAd);
public void initStartApp(String appID, Boolean disableReturnAd, Boolean disableSplashAd, Boolean userConsent, CallbackContext callbackContext) {
Log.d(TAG, "Initializing StartApp SDK with ID: " + appID + " ReturnAd: " + disableReturnAd + " SplashAd: " + disableSplashAd + " UserConsent: " + userConsent);
startAppAd = new StartAppAd(cordova.getActivity());
StartAppSDK.init(cordova.getActivity(), appID, disableReturnAd);
StartAppSDK.setUserConsent(cordova.getActivity(), "pas", System.currentTimeMillis(), false);
StartAppSDK.setUserConsent(cordova.getActivity(), "pas", System.currentTimeMillis(), userConsent);

if (disableSplashAd) {
StartAppAd.disableSplash();
Expand Down
4 changes: 2 additions & 2 deletions www/startappads.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ var exec = require('cordova/exec');

var StartAppAds = {
init: function(appid, options) {
var DEFAULT_OPTIONS = { returnAd: true, splashAd: true };
var DEFAULT_OPTIONS = { returnAd: true, splashAd: true, userConsent: false };

if (typeof options !== "object") { options = DEFAULT_OPTIONS; }
options = Object.assign(DEFAULT_OPTIONS, options);

exec(function(){}, function(){}, "StartAppAdsPlugin", "initStartApp", [appid, !options.returnAd, !options.splashAd]);
exec(function(){}, function(){}, "StartAppAdsPlugin", "initStartApp", [appid, !options.returnAd, !options.splashAd, options.userConsent]);
},
showBanner: function() {
exec(function(){}, function(){}, "StartAppAdsPlugin", "showBanner", []);
Expand Down

0 comments on commit bccf3bf

Please sign in to comment.