Skip to content

Commit

Permalink
added extended attribution info
Browse files Browse the repository at this point in the history
  • Loading branch information
tapasyat committed Feb 14, 2024
1 parent 0c7d10f commit d57b13a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
51 changes: 45 additions & 6 deletions Sources/mParticle-Singular/MPKitSingular.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#import <Singular/Singular.h>
#import <Singular/SingularConfig.h>


NSUInteger MPKitInstanceSingularKitId = 119;

@implementation MPKitSingular
Expand All @@ -23,17 +22,23 @@ @implementation MPKitSingular
#define MPARTICLE_WRAPPER_NAME @"mParticle"
#define MPARTICLE_WRAPPER_VERSION @"1.2.0"


NSString *apiKey;
NSString *secret;
int ddlTimeout = 60;
void (^singularLinkHandler) (SingularLinkParams*);
typedef void (^sdidAccessorHandler)(NSString*);

static bool isSKANEnabled = NO;
static bool isManualMode = NO;
static void(^conversionValueUpdatedCallback)(NSInteger);
static int waitForTrackingAuthorizationWithTimeoutInterval = 0;
static bool isInitialized = NO;
static NSString* customSDID;
static sdidAccessorHandler sdidReceiveHandler;
static sdidAccessorHandler didSetSdidHandler;

static void(^deviceAttributionCallback)(NSDictionary *);
/*
mParticle will supply a unique kit code for you. Please contact our team
*/
Expand Down Expand Up @@ -96,11 +101,21 @@ - (void)start{
[Singular setWrapperName:MPARTICLE_WRAPPER_NAME andVersion:MPARTICLE_WRAPPER_VERSION];

singularLinkHandler = ^(SingularLinkParams * params) {
NSDictionary *linkInfo = [[NSDictionary alloc]
initWithObjectsAndKeys:[params getDeepLink] ,SINGULAR_DEEPLINK_KEY,
[params getPassthrough], SINGULAR_PASSTHROUGH_KEY,
[NSNumber numberWithBool:[params isDeferred]], SINGULAR_IS_DEFERRED_KEY,
nil];
NSMutableDictionary *linkInfo = [[NSMutableDictionary alloc]init];

if ([params getDeepLink] != nil) {
[linkInfo setObject:[params getDeepLink] forKey:SINGULAR_DEEPLINK_KEY];
}

if ([params getPassthrough] != nil) {
[linkInfo setObject:[params getPassthrough] forKey:SINGULAR_PASSTHROUGH_KEY];
}

if ([params getUrlParameters] != nil) {
[linkInfo setObject:[params getUrlParameters] forKey:SINGULAR_QUERY_PARAMS];
}

[linkInfo setObject:[NSNumber numberWithBool:[params isDeferred]] forKey:SINGULAR_IS_DEFERRED_KEY];

MPAttributionResult *attributionResult = [[MPAttributionResult alloc] init];
attributionResult.linkInfo = linkInfo;
Expand Down Expand Up @@ -370,6 +385,12 @@ - (SingularConfig*)buildSingularConfig {

config.singularLinksHandler = singularLinkHandler;

config.customSdid = customSDID;
config.sdidReceivedHandler = sdidReceiveHandler;
config.didSetSdidHandler = didSetSdidHandler;

config.deviceAttributionCallback = deviceAttributionCallback;

config.skAdNetworkEnabled = isSKANEnabled;
config.manualSkanConversionManagement = isManualMode;
config.conversionValueUpdatedCallback = conversionValueUpdatedCallback;
Expand All @@ -389,4 +410,22 @@ + (void)setSKANOptions:(BOOL)skAdNetworkEnabled isManualSkanConversionManagement
waitForTrackingAuthorizationWithTimeoutInterval = waitTrackingAuthorizationWithTimeoutInterval ? [waitTrackingAuthorizationWithTimeoutInterval intValue] : 0;
}

+ (void)setCustomSDID:(NSString *)customSdid sdidReceivedHandler:(void(^_Nullable)(NSString *))sdidReceivedHandler didSetSdidHandler:(void(^_Nullable)(NSString *))setSdidHandler {
if (isInitialized) {
NSLog(@"Singular Warning: setCustomSDID should be called before init");
}

customSDID = customSdid;
sdidReceiveHandler = sdidReceivedHandler;
didSetSdidHandler = setSdidHandler;
}

+ (void)setDeviceAttributionCallback:(void(^_Nullable)(NSDictionary*))deviceAttributionHandler {
if (isInitialized) {
NSLog(@"Singular Warning: setDeviceAttributionHandler should be called before init");
}

deviceAttributionCallback = deviceAttributionHandler;
}

@end
5 changes: 5 additions & 0 deletions Sources/mParticle-Singular/include/MPKitSingular.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define SINGULAR_DEEPLINK_KEY @"singular_deeplink"
#define SINGULAR_PASSTHROUGH_KEY @"singular_passthrough"
#define SINGULAR_IS_DEFERRED_KEY @"singular_is_deferred"
#define SINGULAR_QUERY_PARAMS @"singular_query_params"

@interface MPKitSingular : NSObject <MPKitProtocol>

Expand All @@ -24,4 +25,8 @@

+(void)setSKANOptions:(BOOL)skAdNetworkEnabled isManualSkanConversionManagementMode:(BOOL)manualMode withWaitForTrackingAuthorizationWithTimeoutInterval:(NSNumber* _Nullable)waitTrackingAuthorizationWithTimeoutInterval withConversionValueUpdatedHandler:(void(^_Nullable)(NSInteger))conversionValueUpdatedHandler;

+ (void)setDeviceAttributionCallback:(void(^_Nullable)(NSDictionary*_Nullable))deviceAttributionHandler;

+ (void)setCustomSDID:(NSString *_Nullable)customSdid sdidReceivedHandler:(void(^_Nullable)(NSString *_Nullable))sdidReceivedHandler didSetSdidHandler:(void(^_Nullable)(NSString *_Nullable))setSdidHandler;

@end

0 comments on commit d57b13a

Please sign in to comment.