Hi. I am trying to use the AmazonAdvertising api for the getAdvertisingId and getLimitAdTrackingPreference methods to get the user's ad tracking preferences.
I followed the instructions for including the Amazon web api, making a little test page that loads the api and attempts to make a call.
What I am finding is that when I run from the Web App Tester, everything works fine: the api loads, the amazonPlatformReady event fires, i can get the ad id.
However, when I use a WebView in a native app, the api fails to load, the amazonPlatformReady event never fires.
The Amazon web api is supposed to be available to web views as well is it not?
Here is the test page I was using.
<!DOCTYPE html>
<html>
<head>
<title>AmazonAdvertising Test Page</title>
</head>
<body>
<h2 style="padding: 2em">Ad Id: <span id="ad-id">???</span></h2>
<script src="https://resources.amazonwebapps.com/v1/latest/Amazon-Web-App-API.min.js"></script>;
<script>
function onAmazonPlatformReady() {
var AmazonAdvertising = window.AmazonAdvertising;
console.log("amazonPlatformReady: AmazonAdvertising: " + AmazonAdvertising);
AmazonAdvertising.getAdvertisingId(adId => {
console.log('getAdvertisingId: ' + adId);
var display = document.querySelector('#ad-id');
display.innerText = adId;
}, errMsg => {
console.error('getAdvertisingId: ' + errMsg);
});
}
document.addEventListener("amazonPlatformReady" , onAmazonPlatformReady, false);
</script>
</body>
</html>