Skip to content

Commit 3b01bfa

Browse files
feat: Add IDFA and IDFV Support for FilteredMParticleUser
1 parent 24f7685 commit 3b01bfa

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

mParticle-Apple-SDK/Identity/FilteredMParticleUser.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ -(BOOL)isLoggedIn {
3939
return self.user.isLoggedIn;
4040
}
4141

42+
-(NSString *)idfa {
43+
NSNumber *currentStatus = [MParticle sharedInstance].stateMachine.attAuthorizationStatus;
44+
if (currentStatus != nil && currentStatus.integerValue == MPATTAuthorizationStatusAuthorized) {
45+
return self.user.identities[@(MPIdentityIOSAdvertiserId)];
46+
}
47+
return nil;
48+
}
49+
50+
-(NSString *)idfv {
51+
return self.user.identities[@(MPIdentityIOSVendorId)];
52+
}
53+
4254
-(NSDictionary<NSNumber *, NSString *> *) userIdentities {
4355
NSDictionary<NSNumber *, NSString *> *unfilteredUserIdentities = self.user.identities;
4456
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)