2015-03-23 15:07:33 -07: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-10 19:11:28 -07:00
|
|
|
|
2015-06-25 01:59:17 -07:00
|
|
|
#import <AdSupport/ASIdentifierManager.h>
|
|
|
|
|
2015-03-10 19:11:28 -07:00
|
|
|
#import "RCTAdSupport.h"
|
2015-07-07 08:47:23 -07:00
|
|
|
#import "RCTUtils.h"
|
2015-03-10 19:11:28 -07:00
|
|
|
|
|
|
|
@implementation RCTAdSupport
|
|
|
|
|
2015-04-09 08:46:53 -07:00
|
|
|
RCT_EXPORT_MODULE()
|
2015-03-10 19:11:28 -07:00
|
|
|
|
2015-04-09 08:46:53 -07:00
|
|
|
RCT_EXPORT_METHOD(getAdvertisingId:(RCTResponseSenderBlock)callback
|
2015-07-07 08:47:23 -07:00
|
|
|
withErrorCallback:(RCTResponseErrorBlock)errorCallback)
|
2015-04-09 08:46:53 -07:00
|
|
|
{
|
2015-07-06 10:22:02 -07:00
|
|
|
NSUUID *advertisingIdentifier = [ASIdentifierManager sharedManager].advertisingIdentifier;
|
|
|
|
if (advertisingIdentifier) {
|
|
|
|
callback(@[advertisingIdentifier.UUIDString]);
|
2015-03-10 19:11:28 -07:00
|
|
|
} else {
|
2015-07-07 08:47:23 -07:00
|
|
|
errorCallback(RCTErrorWithMessage(@"Advertising identifier is unavailable."));
|
2015-03-10 19:11:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-09 08:46:53 -07:00
|
|
|
RCT_EXPORT_METHOD(getAdvertisingTrackingEnabled:(RCTResponseSenderBlock)callback
|
2015-07-06 10:22:02 -07:00
|
|
|
withErrorCallback:(__unused RCTResponseSenderBlock)errorCallback)
|
2015-03-13 15:30:31 -07:00
|
|
|
{
|
2015-07-06 10:22:02 -07:00
|
|
|
callback(@[@([ASIdentifierManager sharedManager].advertisingTrackingEnabled)]);
|
2015-03-13 15:30:31 -07:00
|
|
|
}
|
|
|
|
|
2015-03-10 19:11:28 -07:00
|
|
|
@end
|