Skip to content

Commit dbcd622

Browse files
committed
feat(api): adding purchase track method to manually track purchases outside IAPs.
1 parent aba7320 commit dbcd622

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

Leanplum-SDK/Classes/Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ OBJC_EXPORT NSString *LP_PARAM_INBOX_MESSAGES;
239239
OBJC_EXPORT NSString *LP_PARAM_INBOX_MESSAGE_ID;
240240
OBJC_EXPORT NSString *LP_PARAM_RICH_PUSH_ENABLED;
241241
OBJC_EXPORT NSString *LP_PARAM_UUID;
242+
OBJC_EXPORT NSString *LP_PARAM_CURRENCY_CODE;
242243

243244
OBJC_EXPORT NSString *LP_KEY_VARS;
244245
OBJC_EXPORT NSString *LP_KEY_MESSAGES;

Leanplum-SDK/Classes/Constants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ - (id)init {
174174
NSString *LP_PARAM_INBOX_MESSAGE_ID = @"newsfeedMessageId";
175175
NSString *LP_PARAM_RICH_PUSH_ENABLED = @"richPushEnabled";
176176
NSString *LP_PARAM_UUID = @"uuid";
177+
NSString *LP_PARAM_CURRENCY_CODE = @"currencyCode";
177178

178179
NSString *LP_KEY_REASON = @"reason";
179180
NSString *LP_KEY_STACK_TRACE = @"stackTrace";

Leanplum-SDK/Classes/Leanplum.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,13 @@ typedef NS_ENUM(NSUInteger, LPTrackScreenMode) {
550550
*/
551551
+ (void)trackAllAppScreensWithMode:(LPTrackScreenMode)trackScreenMode;
552552

553+
/**
554+
* Manually track purchase event with currency code in your application. It is advised to use
555+
* trackInAppPurchases to automatically track IAPs.
556+
*/
557+
+ (void)trackPurchase:(NSString *)event withValue:(double)value
558+
andCurrencyCode:(NSString *)currencyCode andParameters:(NSDictionary *)params;
559+
553560
/**
554561
* Automatically tracks InApp purchase and does server side receipt validation.
555562
*/

Leanplum-SDK/Classes/Leanplum.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,23 @@ + (void)trackAllAppScreensWithMode:(LPTrackScreenMode)trackScreenMode;
18001800
LP_END_TRY
18011801
}
18021802

1803+
+ (void)trackPurchase:(NSString *)event withValue:(double)value
1804+
andCurrencyCode:(NSString *)currencyCode andParameters:(NSDictionary *)params
1805+
{
1806+
RETURN_IF_NOOP;
1807+
LP_TRY
1808+
NSMutableDictionary *arguments = [NSMutableDictionary new];
1809+
if (currencyCode) {
1810+
arguments[LP_PARAM_CURRENCY_CODE] = currencyCode;
1811+
}
1812+
1813+
[Leanplum track:event
1814+
withValue:value
1815+
andArgs:arguments
1816+
andParameters:params];
1817+
LP_END_TRY
1818+
}
1819+
18031820
+ (void)trackInAppPurchases
18041821
{
18051822
RETURN_IF_NOOP;

0 commit comments

Comments
 (0)