-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated ios source. Added basic implementation of plugin and initSess…
…ion method
- Loading branch information
1 parent
6b6e246
commit 5ecc2fc
Showing
21 changed files
with
1,980 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// BranchSDK.h | ||
// Branch-TestBed | ||
// | ||
// Created by Lysis on 1/14/16. | ||
// Copyright © 2016 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import <Cordova/CDV.h> | ||
|
||
@interface BranchSDK : CDVPlugin | ||
|
||
- (void)initSession:(CDVInvokedUrlCommand*)command; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// | ||
// BranchSDK.m | ||
// Branch-TestBed | ||
// | ||
// Created by Lysis on 1/14/16. | ||
// Copyright © 2016 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import "BranchSDK.h" | ||
#import <Branch/Branch.h> | ||
#import <Cordova/CDV.h> | ||
|
||
@implementation BranchSDK | ||
|
||
#pragma mark - Private APIs | ||
#pragma mark - Global Instance Accessors | ||
|
||
- (Branch *)getInstance | ||
{ | ||
NSLog(@"start getInstance"); | ||
return [Branch getInstance]; | ||
} | ||
|
||
- (Branch *)getInstance:(NSString *)branchKey | ||
{ | ||
NSLog(@"start getInstance with branchKey"); | ||
if (branchKey) { | ||
return [Branch getInstance:branchKey]; | ||
} | ||
else { | ||
return [Branch getInstance]; | ||
} | ||
} | ||
|
||
- (Branch *)getTestInstance | ||
{ | ||
NSLog(@"start getTestInstance"); | ||
return [Branch getTestInstance]; | ||
} | ||
|
||
- (void)setDebug:(id)args | ||
{ | ||
NSLog(@"start setDebug"); | ||
[[Branch getInstance] setDebug]; | ||
} | ||
|
||
#pragma mark Public APIs | ||
#pragma mark - InitSession Permutation methods | ||
|
||
- (void)initSession:(CDVInvokedUrlCommand*)command | ||
{ | ||
NSLog(@"start initSession"); | ||
Branch *branch = [self getInstance]; | ||
|
||
[branch initSessionAndRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) { | ||
NSLog(@"inside initSessionAndRegisterDeepLinkHandler"); | ||
CDVPluginResult* pluginResult = nil; | ||
if (!error) { | ||
if (params != nil && [params count] > 0) { | ||
NSError *err; | ||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params | ||
options:0 | ||
error:&err]; | ||
if (!jsonData) { | ||
NSLog(@"Parsing Error: %@", [err localizedDescription]); | ||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[err localizedDescription]]; | ||
} else { | ||
NSLog(@"Success"); | ||
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | ||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString]; | ||
} | ||
} else { | ||
NSLog(@"No data found"); | ||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Empty data"]; | ||
} | ||
} | ||
else { | ||
NSLog(@"Init Error: %@", [error localizedDescription]); | ||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; | ||
} | ||
NSLog(@"returning data to js interface.."); | ||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; | ||
}]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Versions/Current/Branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Versions/Current/Headers |
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCConfig.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// BNCConfig.h | ||
// Branch-SDK | ||
// | ||
// Created by Qinwei Gong on 10/6/14. | ||
// Copyright (c) 2014 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#ifndef Branch_SDK_Config_h | ||
#define Branch_SDK_Config_h | ||
|
||
#define SDK_VERSION @"0.11.14" | ||
|
||
#define BNC_PROD_ENV | ||
//#define BNC_STAGE_ENV | ||
//#define BNC_DEV_ENV | ||
|
||
#ifdef BNC_PROD_ENV | ||
#define BNC_API_BASE_URL @"https://api.branch.io" | ||
#endif | ||
|
||
#ifdef BNC_STAGE_ENV | ||
#define BNC_API_BASE_URL @"http://api.dev.branchmetrics.io" | ||
#endif | ||
|
||
#define BNC_LINK_URL @"https://bnc.lt" | ||
|
||
#ifdef BNC_DEV_ENV | ||
#define BNC_API_BASE_URL @"http://localhost:3001" | ||
#endif | ||
|
||
#define BNC_API_VERSION @"v1" | ||
|
||
#endif |
17 changes: 17 additions & 0 deletions
17
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCLinkCache.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// BNCLinkCache.h | ||
// Branch-SDK | ||
// | ||
// Created by Qinwei Gong on 1/23/15. | ||
// Copyright (c) 2015 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "BNCLinkData.h" | ||
|
||
@interface BNCLinkCache : NSObject | ||
|
||
- (void)setObject:(NSString *)anObject forKey:(BNCLinkData *)aKey; | ||
- (NSString *)objectForKey:(BNCLinkData *)aKey; | ||
|
||
@end |
30 changes: 30 additions & 0 deletions
30
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCLinkData.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// BNCLinkData.h | ||
// Branch-SDK | ||
// | ||
// Created by Qinwei Gong on 1/22/15. | ||
// Copyright (c) 2015 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
typedef NS_ENUM(NSUInteger, BranchLinkType) { | ||
BranchLinkTypeUnlimitedUse = 0, | ||
BranchLinkTypeOneTimeUse = 1 | ||
}; | ||
|
||
@interface BNCLinkData : NSObject | ||
|
||
@property (strong, nonatomic) NSMutableDictionary *data; | ||
|
||
- (void)setupTags:(NSArray *)tags; | ||
- (void)setupAlias:(NSString *)alias; | ||
- (void)setupType:(BranchLinkType)type; | ||
- (void)setupChannel:(NSString *)channel; | ||
- (void)setupFeature:(NSString *)feature; | ||
- (void)setupStage:(NSString *)stage; | ||
- (void)setupParams:(NSDictionary *)params; | ||
- (void)setupMatchDuration:(NSUInteger)duration; | ||
- (void)setupIgnoreUAString:(NSString *)ignoreUAString; | ||
|
||
@end |
65 changes: 65 additions & 0 deletions
65
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCPreferenceHelper.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// BNCPreferenceHelper.h | ||
// Branch-SDK | ||
// | ||
// Created by Alex Austin on 6/6/14. | ||
// Copyright (c) 2014 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#define FILE_NAME [[NSString stringWithUTF8String:__FILE__] lastPathComponent] | ||
#define LINE_NUM __LINE__ | ||
|
||
@interface BNCPreferenceHelper : NSObject | ||
|
||
@property (strong, nonatomic) NSString *branchKey; | ||
@property (strong, nonatomic) NSString *appKey; | ||
@property (strong, nonatomic) NSString *lastRunBranchKey; | ||
@property (strong, nonatomic) NSDate *lastStrongMatchDate; | ||
@property (strong, nonatomic) NSString *appVersion; | ||
@property (strong, nonatomic) NSString *deviceFingerprintID; | ||
@property (strong, nonatomic) NSString *sessionID; | ||
@property (strong, nonatomic) NSString *identityID; | ||
@property (strong, nonatomic) NSString *linkClickIdentifier; | ||
@property (strong, nonatomic) NSString *spotlightIdentifier; | ||
@property (strong, nonatomic) NSString *universalLinkUrl; | ||
@property (strong, nonatomic) NSString *userUrl; | ||
@property (strong, nonatomic) NSString *userIdentity; | ||
@property (strong, nonatomic) NSString *sessionParams; | ||
@property (strong, nonatomic) NSString *installParams; | ||
@property (assign, nonatomic) BOOL explicitlyRequestedReferrable; | ||
@property (assign, nonatomic) BOOL isReferrable; | ||
@property (assign, nonatomic) BOOL isDebug; | ||
@property (assign, nonatomic) BOOL isContinuingUserActivity; | ||
@property (assign, nonatomic) NSInteger retryCount; | ||
@property (assign, nonatomic) NSTimeInterval retryInterval; | ||
@property (assign, nonatomic) NSTimeInterval timeout; | ||
@property (strong, nonatomic) NSString *externalIntentURI; | ||
|
||
+ (BNCPreferenceHelper *)preferenceHelper; | ||
|
||
- (NSString *)getAPIBaseURL; | ||
- (NSString *)getAPIURL:(NSString *)endpoint; | ||
- (NSString *)getBranchKey:(BOOL)isLive; | ||
|
||
- (void)clearUserCreditsAndCounts; | ||
- (void)clearUserCredits; | ||
|
||
- (id)getBranchUniversalLinkDomains; | ||
|
||
- (void)setCreditCount:(NSInteger)count; | ||
- (void)setCreditCount:(NSInteger)count forBucket:(NSString *)bucket; | ||
- (void)removeCreditCountForBucket:(NSString *)bucket; | ||
- (NSDictionary *)getCreditDictionary; | ||
- (NSInteger)getCreditCount; | ||
- (NSInteger)getCreditCountForBucket:(NSString *)bucket; | ||
|
||
- (void)setActionTotalCount:(NSString *)action withCount:(NSInteger)count; | ||
- (void)setActionUniqueCount:(NSString *)action withCount:(NSInteger)count; | ||
- (NSInteger)getActionTotalCount:(NSString *)action; | ||
- (NSInteger)getActionUniqueCount:(NSString *)action; | ||
|
||
- (void)log:(NSString *)filename line:(int)line message:(NSString *)format, ...; | ||
|
||
@end |
36 changes: 36 additions & 0 deletions
36
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCServerInterface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// BNCServerInterface.h | ||
// Branch-SDK | ||
// | ||
// Created by Alex Austin on 6/4/14. | ||
// Copyright (c) 2014 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "BNCServerResponse.h" | ||
#import "BNCPreferenceHelper.h" | ||
|
||
typedef void (^BNCServerCallback)(BNCServerResponse *response, NSError *error); | ||
|
||
static NSString *REQ_TAG_DEBUG_CONNECT = @"t_debug_connect"; | ||
static NSString *REQ_TAG_DEBUG_LOG = @"t_debug_log"; | ||
static NSString *REQ_TAG_DEBUG_SCREEN = @"t_debug_screen"; | ||
static NSString *REQ_TAG_DEBUG_DISCONNECT = @"t_debug_disconnect"; | ||
|
||
@interface BNCServerInterface : NSObject | ||
|
||
@property (strong, nonatomic) BNCPreferenceHelper *preferenceHelper; | ||
|
||
- (BNCServerResponse *)getRequest:(NSDictionary *)params url:(NSString *)url key:(NSString *)key; | ||
- (BNCServerResponse *)getRequest:(NSDictionary *)params url:(NSString *)url key:(NSString *)key log:(BOOL)log; | ||
- (void)getRequest:(NSDictionary *)params url:(NSString *)url key:(NSString *)key callback:(BNCServerCallback)callback; | ||
- (void)getRequest:(NSDictionary *)params url:(NSString *)url key:(NSString *)key log:(BOOL)log callback:(BNCServerCallback)callback; | ||
|
||
- (BNCServerResponse *)postRequest:(NSDictionary *)post url:(NSString *)url key:(NSString *)key log:(BOOL)log; | ||
- (void)postRequest:(NSDictionary *)post url:(NSString *)url key:(NSString *)key callback:(BNCServerCallback)callback; | ||
- (void)postRequest:(NSDictionary *)post url:(NSString *)url key:(NSString *)key log:(BOOL)log callback:(BNCServerCallback)callback; | ||
|
||
- (void)genericHTTPRequest:(NSURLRequest *)request log:(BOOL)log callback:(BNCServerCallback)callback; | ||
- (BNCServerResponse *)genericHTTPRequest:(NSURLRequest *)request log:(BOOL)log; | ||
|
||
@end |
17 changes: 17 additions & 0 deletions
17
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCServerRequest.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// BNCServerRequest.h | ||
// Branch-SDK | ||
// | ||
// Created by Alex Austin on 6/5/14. | ||
// Copyright (c) 2014 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "BNCServerInterface.h" | ||
|
||
@interface BNCServerRequest : NSObject <NSCoding> | ||
|
||
- (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback; | ||
- (void)processResponse:(BNCServerResponse *)response error:(NSError *)error; | ||
|
||
@end |
34 changes: 34 additions & 0 deletions
34
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCServerRequestQueue.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// BNCServerRequestQueue.h | ||
// Branch-SDK | ||
// | ||
// Created by Qinwei Gong on 9/6/14. | ||
// | ||
// | ||
|
||
#import "BNCServerRequest.h" | ||
|
||
@class BranchOpenRequest; | ||
|
||
@interface BNCServerRequestQueue : NSObject | ||
|
||
@property (nonatomic, readonly) unsigned int size; | ||
|
||
- (void)enqueue:(BNCServerRequest *)request; | ||
- (BNCServerRequest *)dequeue; | ||
- (BNCServerRequest *)peek; | ||
- (BNCServerRequest *)peekAt:(unsigned int)index; | ||
- (void)insert:(BNCServerRequest *)request at:(unsigned int)index; | ||
- (BNCServerRequest *)removeAt:(unsigned int)index; | ||
- (void)remove:(BNCServerRequest *)request; | ||
- (void)persistEventually; | ||
- (void)persistImmediately; | ||
- (void)clearQueue; | ||
|
||
- (BOOL)containsInstallOrOpen; | ||
- (BOOL)containsClose; | ||
- (BranchOpenRequest *)moveInstallOrOpenToFront:(NSInteger)networkCount; | ||
|
||
+ (id)getInstance; | ||
|
||
@end |
16 changes: 16 additions & 0 deletions
16
src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCServerResponse.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// BNCServerResponse.h | ||
// Branch-SDK | ||
// | ||
// Created by Qinwei Gong on 10/10/14. | ||
// Copyright (c) 2014 Branch Metrics. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface BNCServerResponse : NSObject | ||
|
||
@property (nonatomic, strong) NSNumber *statusCode; | ||
@property (nonatomic, strong) id data; | ||
|
||
@end |
Oops, something went wrong.