Skip to content

Commit 10fdb68

Browse files
feat: Add IDFA and IDFV Support for FilteredMParticleUser
1 parent e9ab9d6 commit 10fdb68

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

mParticle-Apple-SDK/Identity/FilteredMParticleUser.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#import "FilteredMParticleUser.h"
22
#import "mParticle.h"
33
#import "MParticleUser.h"
4+
#import "MPStateMachine.h"
45
#import "MPKitConfiguration.h"
56
#import "MPDataPlanFilter.h"
67
#import "MParticleSwift.h"
78

89
@interface MParticle ()
910

1011
@property (nonatomic, strong) id<MPDataPlanFilterProtocol> dataPlanFilter;
12+
@property (nonatomic, strong, readonly) MPStateMachine_PRIVATE *stateMachine;
1113

1214
@end
1315

@@ -39,6 +41,18 @@ -(BOOL)isLoggedIn {
3941
return self.user.isLoggedIn;
4042
}
4143

44+
-(NSString *)idfa {
45+
NSNumber *currentStatus = [MParticle sharedInstance].stateMachine.attAuthorizationStatus;
46+
if (currentStatus != nil && currentStatus.integerValue == MPATTAuthorizationStatusAuthorized) {
47+
return self.user.identities[@(MPIdentityIOSAdvertiserId)];
48+
}
49+
return nil;
50+
}
51+
52+
-(NSString *)idfv {
53+
return self.user.identities[@(MPIdentityIOSVendorId)];
54+
}
55+
4256
-(NSDictionary<NSNumber *, NSString *> *) userIdentities {
4357
NSDictionary<NSNumber *, NSString *> *unfilteredUserIdentities = self.user.identities;
4458
NSMutableDictionary *userIdentities = [NSMutableDictionary dictionary];

mParticle-Apple-SDK/Include/FilteredMParticleUser.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323
*/
2424
@property (readonly, strong, nonnull) NSDictionary<NSNumber *, NSString *> *userIdentities;
2525

26+
/**
27+
Gets current user's IDFA (readonly)
28+
@returns A string that represents a unique, resettable device identifier that allows developers to track user activity for personalized ads. This will always be nil if ATTStatus is not set to authorized.
29+
@see MPIdentityIOSAdvertiserId
30+
*/
31+
@property (readonly, strong, nullable) NSString *idfa;
32+
33+
/**
34+
Gets current user's IDFV (readonly)
35+
@returns A string that represents a unique, non-resettable alphanumeric code Apple assigns to a specific device, identical for all apps from the same developer on that device.
36+
@see MPIdentityIOSVendorId
37+
*/
38+
@property (readonly, strong, nullable) NSString *idfv;
39+
2640
/**
2741
Gets all user attributes.
2842
@returns A dictionary containing the collection of user attributes.

0 commit comments

Comments
 (0)