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-11 02:11:28 +00:00
|
|
|
|
2015-06-25 08:59:17 +00:00
|
|
|
#import <AdSupport/ASIdentifierManager.h>
|
|
|
|
|
2015-03-11 02:11:28 +00:00
|
|
|
#import "RCTAdSupport.h"
|
|
|
|
|
|
|
|
@implementation RCTAdSupport
|
|
|
|
|
2015-04-09 15:46:53 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
2015-03-11 02:11:28 +00:00
|
|
|
|
2015-04-09 15:46:53 +00:00
|
|
|
RCT_EXPORT_METHOD(getAdvertisingId:(RCTResponseSenderBlock)callback
|
|
|
|
withErrorCallback:(RCTResponseSenderBlock)errorCallback)
|
|
|
|
{
|
2015-03-11 02:11:28 +00:00
|
|
|
if ([ASIdentifierManager class]) {
|
|
|
|
callback(@[[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]]);
|
|
|
|
} else {
|
|
|
|
return errorCallback(@[@"as_identifier_unavailable"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-09 15:46:53 +00:00
|
|
|
RCT_EXPORT_METHOD(getAdvertisingTrackingEnabled:(RCTResponseSenderBlock)callback
|
|
|
|
withErrorCallback:(RCTResponseSenderBlock)errorCallback)
|
2015-03-13 22:30:31 +00:00
|
|
|
{
|
|
|
|
if ([ASIdentifierManager class]) {
|
2015-04-09 15:46:53 +00:00
|
|
|
BOOL hasTracking = [[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled];
|
2015-03-13 22:30:31 +00:00
|
|
|
callback(@[@(hasTracking)]);
|
|
|
|
} else {
|
|
|
|
return errorCallback(@[@"as_identifier_unavailable"]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-11 02:11:28 +00:00
|
|
|
@end
|