Skip to content

Commit c9c601d

Browse files
authored
Merge pull request #270 from BranchMetrics/update-ios-0.12.23
fix: iOS version update and fix custom event with no metadata
2 parents 9d60e4f + 40e83e2 commit c9c601d

23 files changed

+545
-65
lines changed

DEVELOPING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ gulp prerelease;
6868
6969
```sh
7070
gulp prerelease; cd testbed; npm install -g cordova; cordova platform remove ios; cordova platform remove android; cordova platform remove browser; cordova platform add ios; cordova platform add android; cordova plugin remove io.branch.sdk; cordova plugin add ../ --variable BRANCH_KEY=key_live_icCccJIpd7GlYY5oOmoEtpafuDiuyXhT --variable URI_SCHEME=enefftest;
71+
```
72+
73+
```sh
74+
gulp prerelease; cd testbed; rm -rf platforms; rm -rf plugins; cordova platform add ios; cordova platform add android; cordova plugin add ../ --variable BRANCH_KEY=key_live_icCccJIpd7GlYY5oOmoEtpafuDiuyXhT --variable URI_SCHEME=enefftest;
7175

76+
```
77+
78+
```sh
7279
# cordova plugin add branch-cordova-sdk --variable BRANCH_KEY=key_live_icCccJIpd7GlYY5oOmoEtpafuDiuyXhT --variable URI_SCHEME=enefftest;
7380
```
7481

plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ SOFTWARE.
119119
<header-file src="src/ios/dependencies/Fabric/Fabric.h" />
120120

121121
<header-file src="src/ios/dependencies/Branch-SDK/BNCCallbacks.h" />
122+
<header-file src="src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h" />
123+
<source-file src="src/ios/dependencies/Branch-SDK/BNCCommerceEvent.m" />
122124
<header-file src="src/ios/dependencies/Branch-SDK/BNCConfig.h" />
123125
<source-file src="src/ios/dependencies/Branch-SDK/BNCConfig.m" />
124126
<header-file src="src/ios/dependencies/Branch-SDK/BNCContentDiscoveryManager.h" />

src/ios/BranchSDK.m

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ - (void)initSession:(CDVInvokedUrlCommand*)command
9595

9696
if (!error) {
9797
if (params != nil && [params count] > 0 && isFromBranchLink) {
98-
98+
9999
NSError *err;
100100
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:&err];
101101

@@ -136,7 +136,7 @@ - (void)initSession:(CDVInvokedUrlCommand*)command
136136
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"BSDKPostUnhandledURL" object:self.deepLinkUrl]];
137137
}
138138
self.deepLinkUrl = nil;
139-
139+
140140
if (command != nil) {
141141
[self.commandDelegate sendPluginResult: pluginResult callbackId: command.callbackId];
142142
}
@@ -147,7 +147,7 @@ - (void)setMixpanelToken:(CDVInvokedUrlCommand*)command
147147
{
148148

149149
[[Branch getInstance] setRequestMetadataKey:@"$mixpanel_distinct_id" value:[command.arguments objectAtIndex:0]];
150-
150+
151151
}
152152

153153
- (void)setDebug:(CDVInvokedUrlCommand*)command
@@ -208,10 +208,10 @@ - (void)setIdentity:(CDVInvokedUrlCommand*)command
208208
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:params];
209209
}
210210
else {
211-
211+
212212
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
213213
}
214-
214+
215215
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
216216
}];
217217
}
@@ -227,13 +227,14 @@ - (void)userCompletedAction:(CDVInvokedUrlCommand*)command
227227
{
228228
NSString *name;
229229
NSDictionary *state;
230+
230231
// if a state dictionary is passed as an argument
231232
if ([command.arguments count] == 2) {
232233
name = [command.arguments objectAtIndex:0];
233234
state = [command.arguments objectAtIndex:1];
234235
}
235236
else {
236-
name = (NSString *)command.arguments;
237+
name = [command.arguments objectAtIndex:0];
237238
}
238239

239240
Branch *branch = [self getInstance];
@@ -245,7 +246,7 @@ - (void)userCompletedAction:(CDVInvokedUrlCommand*)command
245246
[branch userCompletedAction:name];
246247
}
247248

248-
// TODO: need to resolve according to result of userCompletedAction, but no callback version of the method is exposed.
249+
// TODO: iOS Branch.userCompletedAction needs a callback for success or failure
249250
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"Success"];
250251
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
251252
}
@@ -417,7 +418,7 @@ - (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command
417418
- (void)registerView:(CDVInvokedUrlCommand*)command
418419
{
419420
int branchUniversalObjectId = [[command.arguments objectAtIndex:0] intValue];
420-
421+
421422
NSMutableDictionary *branchUniversalObjDict = [self.branchUniversalObjArray objectAtIndex:branchUniversalObjectId];
422423
BranchUniversalObject *branchUniversalObj = [branchUniversalObjDict objectForKey:@"branchUniversalObj"];
423424

@@ -532,7 +533,7 @@ - (void)showShareSheet:(CDVInvokedUrlCommand*)command
532533
completion:^(NSString *activityType, BOOL completed) {
533534

534535
int listenerCallbackId = [[command.arguments objectAtIndex:0] intValue];
535-
536+
536537
if (completed) {
537538
NSLog(@"Share link complete");
538539
[branchUniversalObj getShortUrlWithLinkProperties:linkProperties andCallback:^(NSString *url, NSError *error) {
@@ -542,7 +543,7 @@ - (void)showShareSheet:(CDVInvokedUrlCommand*)command
542543
}
543544
}];
544545
}
545-
546+
546547
CDVPluginResult *shareDialogDismissed = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
547548

548549
NSMutableDictionary *branchUniversalObjDict = [self.branchUniversalObjArray objectAtIndex:listenerCallbackId];
@@ -615,7 +616,7 @@ - (void)postUnhandledURL:(NSNotification *)notification {
615616
// We create a JSON string result, because we're unable to handle the url. We will include the url in the return string.
616617
NSError *error;
617618
NSString *urlString;
618-
619+
619620
// if ([notification.object respondsToSelector:@selector(absoluteString:)]) {
620621
SEL selector = NSSelectorFromString(@"absoluteString:");
621622
if ([notification.object respondsToSelector:selector]) {
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// BNCCommerceEvent.h
3+
// BranchSDK-iOS
4+
//
5+
// Created by Edward Smith on 12/14/16.
6+
// Copyright (c) 2016 Branch Metrics. All rights reserved.
7+
//
8+
9+
10+
#import <Foundation/Foundation.h>
11+
#import "BNCServerRequest.h"
12+
13+
14+
#pragma mark BNCProductCategory
15+
16+
typedef NSString*const BNCProductCategory;
17+
18+
extern BNCProductCategory BNCProductCategoryAnimalSupplies;
19+
extern BNCProductCategory BNCProductCategoryApparel;
20+
extern BNCProductCategory BNCProductCategoryArtsEntertainment;
21+
extern BNCProductCategory BNCProductCategoryBabyToddler;
22+
extern BNCProductCategory BNCProductCategoryBusinessIndustrial;
23+
extern BNCProductCategory BNCProductCategoryCamerasOptics;
24+
extern BNCProductCategory BNCProductCategoryElectronics;
25+
extern BNCProductCategory BNCProductCategoryFoodBeverageTobacco;
26+
extern BNCProductCategory BNCProductCategoryFurniture;
27+
extern BNCProductCategory BNCProductCategoryHardware;
28+
extern BNCProductCategory BNCProductCategoryHealthBeauty;
29+
extern BNCProductCategory BNCProductCategoryHomeGarden;
30+
extern BNCProductCategory BNCProductCategoryLuggageBags;
31+
extern BNCProductCategory BNCProductCategoryMature;
32+
extern BNCProductCategory BNCProductCategoryMedia;
33+
extern BNCProductCategory BNCProductCategoryOfficeSupplies;
34+
extern BNCProductCategory BNCProductCategoryReligious;
35+
extern BNCProductCategory BNCProductCategorySoftware;
36+
extern BNCProductCategory BNCProductCategorySportingGoods;
37+
extern BNCProductCategory BNCProductCategoryToysGames;
38+
extern BNCProductCategory BNCProductCategoryVehiclesParts;
39+
40+
#pragma mark - BNCProduct
41+
42+
@interface BNCProduct : NSObject
43+
@property (nonatomic, strong) NSString *sku;
44+
@property (nonatomic, strong) NSString *name;
45+
@property (nonatomic, strong) NSDecimalNumber *price;
46+
@property (nonatomic, strong) NSNumber *quantity;
47+
@property (nonatomic, strong) NSString *brand;
48+
@property (nonatomic, strong) BNCProductCategory category;
49+
@property (nonatomic, strong) NSString *variant;
50+
@end
51+
52+
#pragma mark - BNCCommerceEvent
53+
54+
@interface BNCCommerceEvent : NSObject
55+
@property (nonatomic, strong) NSDecimalNumber *revenue;
56+
@property (nonatomic, strong) NSString *currency;
57+
@property (nonatomic, strong) NSString *transactionID;
58+
@property (nonatomic, strong) NSDecimalNumber *shipping;
59+
@property (nonatomic, strong) NSDecimalNumber *tax;
60+
@property (nonatomic, strong) NSString *coupon;
61+
@property (nonatomic, strong) NSString *affiliation;
62+
@property (nonatomic, strong) NSArray<BNCProduct*> *products;
63+
@end
64+
65+
66+
@interface BranchCommerceEventRequest : BNCServerRequest <NSCoding>
67+
68+
- (instancetype) initWithCommerceEvent:(BNCCommerceEvent*)commerceEvent
69+
metadata:(NSDictionary*)dictionary
70+
completion:(void (^)(NSDictionary* response, NSError* error))callBack;
71+
72+
@end

0 commit comments

Comments
 (0)