Skip to content

Commit

Permalink
Merge pull request #270 from BranchMetrics/update-ios-0.12.23
Browse files Browse the repository at this point in the history
fix: iOS version update and fix custom event with no metadata
  • Loading branch information
ethanneff authored Jan 9, 2017
2 parents 9d60e4f + 40e83e2 commit c9c601d
Show file tree
Hide file tree
Showing 23 changed files with 545 additions and 65 deletions.
7 changes: 7 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ gulp prerelease;
```sh
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;
```

```sh
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;

```

```sh
# cordova plugin add branch-cordova-sdk --variable BRANCH_KEY=key_live_icCccJIpd7GlYY5oOmoEtpafuDiuyXhT --variable URI_SCHEME=enefftest;
```

Expand Down
2 changes: 2 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ SOFTWARE.
<header-file src="src/ios/dependencies/Fabric/Fabric.h" />

<header-file src="src/ios/dependencies/Branch-SDK/BNCCallbacks.h" />
<header-file src="src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h" />
<source-file src="src/ios/dependencies/Branch-SDK/BNCCommerceEvent.m" />
<header-file src="src/ios/dependencies/Branch-SDK/BNCConfig.h" />
<source-file src="src/ios/dependencies/Branch-SDK/BNCConfig.m" />
<header-file src="src/ios/dependencies/Branch-SDK/BNCContentDiscoveryManager.h" />
Expand Down
23 changes: 12 additions & 11 deletions src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ - (void)initSession:(CDVInvokedUrlCommand*)command

if (!error) {
if (params != nil && [params count] > 0 && isFromBranchLink) {

NSError *err;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:&err];

Expand Down Expand Up @@ -136,7 +136,7 @@ - (void)initSession:(CDVInvokedUrlCommand*)command
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"BSDKPostUnhandledURL" object:self.deepLinkUrl]];
}
self.deepLinkUrl = nil;

if (command != nil) {
[self.commandDelegate sendPluginResult: pluginResult callbackId: command.callbackId];
}
Expand All @@ -147,7 +147,7 @@ - (void)setMixpanelToken:(CDVInvokedUrlCommand*)command
{

[[Branch getInstance] setRequestMetadataKey:@"$mixpanel_distinct_id" value:[command.arguments objectAtIndex:0]];

}

- (void)setDebug:(CDVInvokedUrlCommand*)command
Expand Down Expand Up @@ -208,10 +208,10 @@ - (void)setIdentity:(CDVInvokedUrlCommand*)command
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:params];
}
else {

pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]];
}

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
Expand All @@ -227,13 +227,14 @@ - (void)userCompletedAction:(CDVInvokedUrlCommand*)command
{
NSString *name;
NSDictionary *state;

// if a state dictionary is passed as an argument
if ([command.arguments count] == 2) {
name = [command.arguments objectAtIndex:0];
state = [command.arguments objectAtIndex:1];
}
else {
name = (NSString *)command.arguments;
name = [command.arguments objectAtIndex:0];
}

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

// TODO: need to resolve according to result of userCompletedAction, but no callback version of the method is exposed.
// TODO: iOS Branch.userCompletedAction needs a callback for success or failure
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"Success"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
Expand Down Expand Up @@ -417,7 +418,7 @@ - (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command
- (void)registerView:(CDVInvokedUrlCommand*)command
{
int branchUniversalObjectId = [[command.arguments objectAtIndex:0] intValue];

NSMutableDictionary *branchUniversalObjDict = [self.branchUniversalObjArray objectAtIndex:branchUniversalObjectId];
BranchUniversalObject *branchUniversalObj = [branchUniversalObjDict objectForKey:@"branchUniversalObj"];

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

int listenerCallbackId = [[command.arguments objectAtIndex:0] intValue];

if (completed) {
NSLog(@"Share link complete");
[branchUniversalObj getShortUrlWithLinkProperties:linkProperties andCallback:^(NSString *url, NSError *error) {
Expand All @@ -542,7 +543,7 @@ - (void)showShareSheet:(CDVInvokedUrlCommand*)command
}
}];
}

CDVPluginResult *shareDialogDismissed = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];

NSMutableDictionary *branchUniversalObjDict = [self.branchUniversalObjArray objectAtIndex:listenerCallbackId];
Expand Down Expand Up @@ -615,7 +616,7 @@ - (void)postUnhandledURL:(NSNotification *)notification {
// We create a JSON string result, because we're unable to handle the url. We will include the url in the return string.
NSError *error;
NSString *urlString;

// if ([notification.object respondsToSelector:@selector(absoluteString:)]) {
SEL selector = NSSelectorFromString(@"absoluteString:");
if ([notification.object respondsToSelector:selector]) {
Expand Down
72 changes: 72 additions & 0 deletions src/ios/dependencies/Branch-SDK/BNCCommerceEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// BNCCommerceEvent.h
// BranchSDK-iOS
//
// Created by Edward Smith on 12/14/16.
// Copyright (c) 2016 Branch Metrics. All rights reserved.
//


#import <Foundation/Foundation.h>
#import "BNCServerRequest.h"


#pragma mark BNCProductCategory

typedef NSString*const BNCProductCategory;

extern BNCProductCategory BNCProductCategoryAnimalSupplies;
extern BNCProductCategory BNCProductCategoryApparel;
extern BNCProductCategory BNCProductCategoryArtsEntertainment;
extern BNCProductCategory BNCProductCategoryBabyToddler;
extern BNCProductCategory BNCProductCategoryBusinessIndustrial;
extern BNCProductCategory BNCProductCategoryCamerasOptics;
extern BNCProductCategory BNCProductCategoryElectronics;
extern BNCProductCategory BNCProductCategoryFoodBeverageTobacco;
extern BNCProductCategory BNCProductCategoryFurniture;
extern BNCProductCategory BNCProductCategoryHardware;
extern BNCProductCategory BNCProductCategoryHealthBeauty;
extern BNCProductCategory BNCProductCategoryHomeGarden;
extern BNCProductCategory BNCProductCategoryLuggageBags;
extern BNCProductCategory BNCProductCategoryMature;
extern BNCProductCategory BNCProductCategoryMedia;
extern BNCProductCategory BNCProductCategoryOfficeSupplies;
extern BNCProductCategory BNCProductCategoryReligious;
extern BNCProductCategory BNCProductCategorySoftware;
extern BNCProductCategory BNCProductCategorySportingGoods;
extern BNCProductCategory BNCProductCategoryToysGames;
extern BNCProductCategory BNCProductCategoryVehiclesParts;

#pragma mark - BNCProduct

@interface BNCProduct : NSObject
@property (nonatomic, strong) NSString *sku;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSDecimalNumber *price;
@property (nonatomic, strong) NSNumber *quantity;
@property (nonatomic, strong) NSString *brand;
@property (nonatomic, strong) BNCProductCategory category;
@property (nonatomic, strong) NSString *variant;
@end

#pragma mark - BNCCommerceEvent

@interface BNCCommerceEvent : NSObject
@property (nonatomic, strong) NSDecimalNumber *revenue;
@property (nonatomic, strong) NSString *currency;
@property (nonatomic, strong) NSString *transactionID;
@property (nonatomic, strong) NSDecimalNumber *shipping;
@property (nonatomic, strong) NSDecimalNumber *tax;
@property (nonatomic, strong) NSString *coupon;
@property (nonatomic, strong) NSString *affiliation;
@property (nonatomic, strong) NSArray<BNCProduct*> *products;
@end


@interface BranchCommerceEventRequest : BNCServerRequest <NSCoding>

- (instancetype) initWithCommerceEvent:(BNCCommerceEvent*)commerceEvent
metadata:(NSDictionary*)dictionary
completion:(void (^)(NSDictionary* response, NSError* error))callBack;

@end
Loading

0 comments on commit c9c601d

Please sign in to comment.