2015-03-11 02:11:28 +00:00
|
|
|
/**
|
2015-03-23 22:07:33 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
2015-03-23 17:06:16 +00:00
|
|
|
* @flow
|
2015-03-11 02:11:28 +00:00
|
|
|
*/
|
|
|
|
'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',
|
2015-03-23 17:06:16 +00:00
|
|
|
render: function(): ReactElement {
|
2015-03-11 02:11:28 +00:00
|
|
|
return <AdSupportIOSExample />;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
var AdSupportIOSExample = React.createClass({
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
deviceID: 'No IDFA yet',
|
2015-03-13 22:30:31 +00:00
|
|
|
hasAdvertiserTracking: 'unset',
|
2015-03-11 02:11:28 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
AdSupportIOS.getAdvertisingId(
|
2015-03-13 22:30:31 +00:00
|
|
|
this._onDeviceIDSuccess,
|
|
|
|
this._onDeviceIDFailure
|
2015-03-11 02:11:28 +00:00
|
|
|
);
|
2015-03-13 22:30:31 +00:00
|
|
|
|
|
|
|
AdSupportIOS.getAdvertisingTrackingEnabled(
|
|
|
|
this._onHasTrackingSuccess,
|
|
|
|
this._onHasTrackingFailure
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onHasTrackingSuccess: function(hasTracking) {
|
|
|
|
this.setState({
|
|
|
|
'hasAdvertiserTracking': hasTracking,
|
|
|
|
});
|
2015-03-11 02:11:28 +00:00
|
|
|
},
|
|
|
|
|
2015-03-13 22:30:31 +00:00
|
|
|
_onHasTrackingFailure: function(e) {
|
|
|
|
this.setState({
|
|
|
|
'hasAdvertiserTracking': 'Error!',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_onDeviceIDSuccess: function(deviceID) {
|
2015-03-11 02:11:28 +00:00
|
|
|
this.setState({
|
|
|
|
'deviceID': deviceID,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-03-13 22:30:31 +00:00
|
|
|
_onDeviceIDFailure: function(e) {
|
2015-03-11 02:11:28 +00: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-13 22:30:31 +00:00
|
|
|
<Text>
|
|
|
|
<Text style={styles.title}>Has Advertiser Tracking: </Text>
|
|
|
|
{JSON.stringify(this.state.hasAdvertiserTracking)}
|
|
|
|
</Text>
|
2015-03-11 02:11:28 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
title: {
|
2015-03-26 01:19:28 +00:00
|
|
|
fontWeight: '500',
|
2015-03-11 02:11:28 +00:00
|
|
|
},
|
|
|
|
});
|