From ca791dfe6f3a4f4d495346474774e827fddbbe59 Mon Sep 17 00:00:00 2001 From: Alex Akers Date: Mon, 6 Jul 2015 10:22:02 -0700 Subject: [PATCH] [React Native] Update RCTAdSupport Summary: No longer check for the `ASIdentifierManager` class. Since we only target iOS 7.0 and up, this is unnecessary. Instead, we should check for whether the `advertisingIdentifier` is non-nil. If it is, we send it; otherwise we send an error. --- Libraries/AdSupport/RCTAdSupport.m | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Libraries/AdSupport/RCTAdSupport.m b/Libraries/AdSupport/RCTAdSupport.m index dff794e34..2e270b035 100644 --- a/Libraries/AdSupport/RCTAdSupport.m +++ b/Libraries/AdSupport/RCTAdSupport.m @@ -18,22 +18,18 @@ RCT_EXPORT_MODULE() RCT_EXPORT_METHOD(getAdvertisingId:(RCTResponseSenderBlock)callback withErrorCallback:(RCTResponseSenderBlock)errorCallback) { - if ([ASIdentifierManager class]) { - callback(@[[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]]); + NSUUID *advertisingIdentifier = [ASIdentifierManager sharedManager].advertisingIdentifier; + if (advertisingIdentifier) { + callback(@[advertisingIdentifier.UUIDString]); } else { - return errorCallback(@[@"as_identifier_unavailable"]); + errorCallback(@[@"as_identifier_unavailable"]); } } RCT_EXPORT_METHOD(getAdvertisingTrackingEnabled:(RCTResponseSenderBlock)callback - withErrorCallback:(RCTResponseSenderBlock)errorCallback) + withErrorCallback:(__unused RCTResponseSenderBlock)errorCallback) { - if ([ASIdentifierManager class]) { - BOOL hasTracking = [[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]; - callback(@[@(hasTracking)]); - } else { - return errorCallback(@[@"as_identifier_unavailable"]); - } + callback(@[@([ASIdentifierManager sharedManager].advertisingTrackingEnabled)]); } @end