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