2015-03-10 12:09:35 -07:00
|
|
|
/**
|
|
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var AdSupportIOS = require('AdSupportIOS');
|
|
|
|
|
|
|
|
var React = require('react-native');
|
|
|
|
var {
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
|
|
|
View,
|
|
|
|
} = React;
|
|
|
|
|
|
|
|
exports.framework = 'React';
|
|
|
|
exports.title = 'Advertising ID';
|
|
|
|
exports.description = 'Example of using the ad support API.';
|
|
|
|
|
|
|
|
exports.examples = [
|
|
|
|
{
|
|
|
|
title: 'Ad Support IOS',
|
|
|
|
render: function() {
|
|
|
|
return <AdSupportIOSExample />;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
var AdSupportIOSExample = React.createClass({
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
deviceID: 'No IDFA yet',
|
2015-03-12 15:57:48 -07:00
|
|
|
hasAdvertiserTracking: 'unset',
|
2015-03-10 12:09:35 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
AdSupportIOS.getAdvertisingId(
|
2015-03-12 15:57:48 -07:00
|
|
|
this._onDeviceIDSuccess,
|
|
|
|
this._onDeviceIDFailure
|
2015-03-10 12:09:35 -07:00
|
|
|
);
|
2015-03-12 15:57:48 -07:00
|
|
|
|
|
|
|
AdSupportIOS.getAdvertisingTrackingEnabled(
|
|
|
|
this._onHasTrackingSuccess,
|
|
|
|
this._onHasTrackingFailure
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onHasTrackingSuccess: function(hasTracking) {
|
|
|
|
this.setState({
|
|
|
|
'hasAdvertiserTracking': hasTracking,
|
|
|
|
});
|
2015-03-10 12:09:35 -07:00
|
|
|
},
|
|
|
|
|
2015-03-12 15:57:48 -07:00
|
|
|
_onHasTrackingFailure: function(e) {
|
|
|
|
this.setState({
|
|
|
|
'hasAdvertiserTracking': 'Error!',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_onDeviceIDSuccess: function(deviceID) {
|
2015-03-10 12:09:35 -07:00
|
|
|
this.setState({
|
|
|
|
'deviceID': deviceID,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-03-12 15:57:48 -07:00
|
|
|
_onDeviceIDFailure: function(e) {
|
2015-03-10 12:09:35 -07:00
|
|
|
this.setState({
|
|
|
|
'deviceID': 'Error!',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<View>
|
|
|
|
<Text>
|
|
|
|
<Text style={styles.title}>Advertising ID: </Text>
|
|
|
|
{JSON.stringify(this.state.deviceID)}
|
|
|
|
</Text>
|
2015-03-12 15:57:48 -07:00
|
|
|
<Text>
|
|
|
|
<Text style={styles.title}>Has Advertiser Tracking: </Text>
|
|
|
|
{JSON.stringify(this.state.hasAdvertiserTracking)}
|
|
|
|
</Text>
|
2015-03-10 12:09:35 -07:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
title: {
|
|
|
|
fontWeight: 'bold',
|
|
|
|
},
|
|
|
|
});
|