diff --git a/Examples/UIExplorer/AdSupportIOSExample.js b/Examples/UIExplorer/AdSupportIOSExample.js
index 63f3a63eb..a3d720f01 100644
--- a/Examples/UIExplorer/AdSupportIOSExample.js
+++ b/Examples/UIExplorer/AdSupportIOSExample.js
@@ -29,23 +29,41 @@ var AdSupportIOSExample = React.createClass({
getInitialState: function() {
return {
deviceID: 'No IDFA yet',
+ hasAdvertiserTracking: 'unset',
};
},
componentDidMount: function() {
AdSupportIOS.getAdvertisingId(
- this._onSuccess,
- this._onFailure
+ this._onDeviceIDSuccess,
+ this._onDeviceIDFailure
+ );
+
+ AdSupportIOS.getAdvertisingTrackingEnabled(
+ this._onHasTrackingSuccess,
+ this._onHasTrackingFailure
);
},
- _onSuccess: function(deviceID) {
+ _onHasTrackingSuccess: function(hasTracking) {
+ this.setState({
+ 'hasAdvertiserTracking': hasTracking,
+ });
+ },
+
+ _onHasTrackingFailure: function(e) {
+ this.setState({
+ 'hasAdvertiserTracking': 'Error!',
+ });
+ },
+
+ _onDeviceIDSuccess: function(deviceID) {
this.setState({
'deviceID': deviceID,
});
},
- _onFailure: function(e) {
+ _onDeviceIDFailure: function(e) {
this.setState({
'deviceID': 'Error!',
});
@@ -58,6 +76,10 @@ var AdSupportIOSExample = React.createClass({
Advertising ID:
{JSON.stringify(this.state.deviceID)}
+
+ Has Advertiser Tracking:
+ {JSON.stringify(this.state.hasAdvertiserTracking)}
+
);
}
diff --git a/Libraries/AdSupport/AdSupportIOS.js b/Libraries/AdSupport/AdSupportIOS.js
index 598befd31..c0a081aa4 100644
--- a/Libraries/AdSupport/AdSupportIOS.js
+++ b/Libraries/AdSupport/AdSupportIOS.js
@@ -11,4 +11,8 @@ module.exports = {
getAdvertisingId: function(onSuccess, onFailure) {
AdSupport.getAdvertisingId(onSuccess, onFailure);
},
+
+ getAdvertisingTrackingEnabled: function(onSuccess, onFailure) {
+ AdSupport.getAdvertisingTrackingEnabled(onSuccess, onFailure);
+ },
};
diff --git a/Libraries/AdSupport/RCTAdSupport.m b/Libraries/AdSupport/RCTAdSupport.m
index 3712b1b9b..22ad6aacb 100644
--- a/Libraries/AdSupport/RCTAdSupport.m
+++ b/Libraries/AdSupport/RCTAdSupport.m
@@ -15,4 +15,16 @@
}
}
+- (void)getAdvertisingTrackingEnabled:(RCTResponseSenderBlock)callback withErrorCallback:(RCTResponseSenderBlock)errorCallback
+{
+ RCT_EXPORT();
+
+ if ([ASIdentifierManager class]) {
+ bool hasTracking = [[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled];
+ callback(@[@(hasTracking)]);
+ } else {
+ return errorCallback(@[@"as_identifier_unavailable"]);
+ }
+}
+
@end