Skip to content

Commit

Permalink
Various cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
uerceg committed Nov 8, 2018
1 parent 5a5c5d8 commit c4e8029
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Adjust.xcodeproj/project.pbxproj
Expand Up @@ -1312,9 +1312,9 @@
96E5E39A18BBB49E008E7B30 /* AdjustTests */ = {
isa = PBXGroup;
children = (
6F0842182007766700568A31 /* AdjustTestLibrary.xcodeproj */,
6F084240200776A000568A31 /* AdjustTestApp.xcodeproj */,
6F7AF63F211878BC00F730B2 /* AdjustWebBridgeTestApp.xcodeproj */,
6F0842182007766700568A31 /* AdjustTestLibrary.xcodeproj */,
6F0841FB2007749C00568A31 /* AdjustUnitTests */,
);
path = AdjustTests;
Expand Down
36 changes: 18 additions & 18 deletions AdjustBridge/AdjustBridge.m
Expand Up @@ -20,13 +20,13 @@ @interface AdjustBridge() <AdjustDelegate>

@property BOOL openDeferredDeeplink;
@property (nonatomic, copy) NSString *fbPixelDefaultEventToken;
@property (nonatomic, strong) NSMutableDictionary* fbPixelMapping;
@property (nonatomic, copy) NSString *attributionCallbackName;
@property (nonatomic, copy) NSString *eventSuccessCallbackName;
@property (nonatomic, copy) NSString *eventFailureCallbackName;
@property (nonatomic, copy) NSString *sessionSuccessCallbackName;
@property (nonatomic, copy) NSString *sessionFailureCallbackName;
@property (nonatomic, copy) NSString *deferredDeeplinkCallbackName;
@property (nonatomic, strong) NSMutableDictionary *fbPixelMapping;

@end

Expand Down Expand Up @@ -75,7 +75,7 @@ - (void)adjustEventTrackingSucceeded:(ADJEventSuccess *)eventSuccessResponseData
[eventSuccessResponseDataDictionary setValue:eventSuccessResponseData.eventToken forKey:@"eventToken"];
[eventSuccessResponseDataDictionary setValue:eventSuccessResponseData.callbackId forKey:@"callbackId"];

NSString * jsonResponse = [self convertJsonDictionaryToNSString:eventSuccessResponseData.jsonResponse];
NSString *jsonResponse = [self convertJsonDictionaryToNSString:eventSuccessResponseData.jsonResponse];
if (jsonResponse == nil) {
jsonResponse = @"{}";
}
Expand All @@ -97,7 +97,7 @@ - (void)adjustEventTrackingFailed:(ADJEventFailure *)eventFailureResponseData {
[eventFailureResponseDataDictionary setValue:eventFailureResponseData.callbackId forKey:@"callbackId"];
[eventFailureResponseDataDictionary setValue:[NSNumber numberWithBool:eventFailureResponseData.willRetry] forKey:@"willRetry"];

NSString * jsonResponse = [self convertJsonDictionaryToNSString:eventFailureResponseData.jsonResponse];
NSString *jsonResponse = [self convertJsonDictionaryToNSString:eventFailureResponseData.jsonResponse];
if (jsonResponse == nil) {
jsonResponse = @"{}";
}
Expand All @@ -116,7 +116,7 @@ - (void)adjustSessionTrackingSucceeded:(ADJSessionSuccess *)sessionSuccessRespon
[sessionSuccessResponseDataDictionary setValue:sessionSuccessResponseData.timeStamp forKey:@"timestamp"];
[sessionSuccessResponseDataDictionary setValue:sessionSuccessResponseData.adid forKey:@"adid"];

NSString * jsonResponse = [self convertJsonDictionaryToNSString:sessionSuccessResponseData.jsonResponse];
NSString *jsonResponse = [self convertJsonDictionaryToNSString:sessionSuccessResponseData.jsonResponse];
if (jsonResponse == nil) {
jsonResponse = @"{}";
}
Expand All @@ -136,7 +136,7 @@ - (void)adjustSessionTrackingFailed:(ADJSessionFailure *)sessionFailureResponseD
[sessionFailureResponseDataDictionary setValue:sessionFailureResponseData.adid forKey:@"adid"];
[sessionFailureResponseDataDictionary setValue:[NSNumber numberWithBool:sessionFailureResponseData.willRetry] forKey:@"willRetry"];

NSString * jsonResponse = [self convertJsonDictionaryToNSString:sessionFailureResponseData.jsonResponse];
NSString *jsonResponse = [self convertJsonDictionaryToNSString:sessionFailureResponseData.jsonResponse];
if (jsonResponse == nil) {
jsonResponse = @"{}";
}
Expand Down Expand Up @@ -217,12 +217,12 @@ - (void)loadWebViewBridge:(id)webView webViewDelegate:(id)webViewDelegate {
NSNumber *openDeferredDeeplink = [data objectForKey:@"openDeferredDeeplink"];
NSString *fbPixelDefaultEventToken = [data objectForKey:@"fbPixelDefaultEventToken"];
id fbPixelMapping = [data objectForKey:@"fbPixelMapping"];
NSString * attributionCallback = [data objectForKey:@"attributionCallback"];
NSString * eventSuccessCallback = [data objectForKey:@"eventSuccessCallback"];
NSString * eventFailureCallback = [data objectForKey:@"eventFailureCallback"];
NSString * sessionSuccessCallback = [data objectForKey:@"sessionSuccessCallback"];
NSString * sessionFailureCallback = [data objectForKey:@"sessionFailureCallback"];
NSString * deferredDeeplinkCallback = [data objectForKey:@"deferredDeeplinkCallback"];
NSString *attributionCallback = [data objectForKey:@"attributionCallback"];
NSString *eventSuccessCallback = [data objectForKey:@"eventSuccessCallback"];
NSString *eventFailureCallback = [data objectForKey:@"eventFailureCallback"];
NSString *sessionSuccessCallback = [data objectForKey:@"sessionSuccessCallback"];
NSString *sessionFailureCallback = [data objectForKey:@"sessionFailureCallback"];
NSString *deferredDeeplinkCallback = [data objectForKey:@"deferredDeeplinkCallback"];

ADJConfig *adjustConfig;
if ([self isFieldValid:allowSuppressLogLevel]) {
Expand Down Expand Up @@ -306,14 +306,13 @@ - (void)loadWebViewBridge:(id)webView webViewDelegate:(id)webViewDelegate {
}

// Set self as delegate if any callback is configured.
// Change to swifle the methods in the future.
// Change to swizzle the methods in the future.
if (self.attributionCallbackName != nil
|| self.eventSuccessCallbackName != nil
|| self.eventFailureCallbackName != nil
|| self.sessionSuccessCallbackName != nil
|| self.sessionFailureCallbackName != nil
|| self.deferredDeeplinkCallbackName != nil)
{
|| self.deferredDeeplinkCallbackName != nil) {
[adjustConfig setDelegate:self];
}

Expand Down Expand Up @@ -418,6 +417,7 @@ - (void)loadWebViewBridge:(id)webView webViewDelegate:(id)webViewDelegate {
if (responseCallback == nil) {
return;
}

ADJAttribution *attribution = [Adjust attribution];
NSDictionary *attributionDictionary = nil;
if (attribution != nil) {
Expand Down Expand Up @@ -483,7 +483,7 @@ - (void)loadWebViewBridge:(id)webView webViewDelegate:(id)webViewDelegate {
NSNumber *noBackoffWait = [data objectForKey:@"noBackoffWait"];
NSNumber *iAdFrameworkEnabled = [data objectForKey:@"iAdFrameworkEnabled"];

AdjustTestOptions * testOptions = [[AdjustTestOptions alloc] init];
AdjustTestOptions *testOptions = [[AdjustTestOptions alloc] init];

if ([self isFieldValid:baseUrl]) {
testOptions.baseUrl = baseUrl;
Expand Down Expand Up @@ -554,7 +554,6 @@ - (void)registerAugmentedView {
}

id customData = [data objectForKey:@"customData"];

[fbPixelEvent addPartnerParameter:@"_fb_pixel_referral_id" value:pixelID];
// [fbPixelEvent addPartnerParameter:@"_eventName" value:evtName];
if ([customData isKindOfClass:[NSString class]]) {
Expand Down Expand Up @@ -589,10 +588,10 @@ - (BOOL)isFieldValid:(NSObject *)field {

- (NSString *)getFbAppId {
NSString *facebookLoggingOverrideAppID = [self getValueFromBundleByKey:@"FacebookLoggingOverrideAppID"];

if (facebookLoggingOverrideAppID != nil) {
return facebookLoggingOverrideAppID;
}

return [self getValueFromBundleByKey:@"FacebookAppID"];
}

Expand All @@ -604,18 +603,19 @@ - (NSString *)getEventTokenFromFbPixelEventName:(NSString *)fbPixelEventName {
if (self.fbPixelMapping == nil) {
return nil;
}

return [self.fbPixelMapping objectForKey:fbPixelEventName];
}

- (NSString *)convertJsonDictionaryToNSString:(NSDictionary *)jsonDictionary {
if (jsonDictionary == nil) {
return nil;
}

NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDictionary
options:NSJSONWritingPrettyPrinted
error:&error];

if (!jsonData) {
NSLog(@"Unable to conver NSDictionary with JSON response to JSON string: %@", error);
return nil;
Expand Down
4 changes: 2 additions & 2 deletions AdjustBridge/AdjustBridgeRegister.h
Expand Up @@ -11,12 +11,12 @@

@interface AdjustBridgeRegister : NSObject

+ (NSString *)AdjustBridge_js;

- (id)initWithWebView:(id)webView;
- (void)setWebViewDelegate:(id)webViewDelegate;

- (void)callHandler:(NSString *)handlerName data:(id)data;
- (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler;
- (void)augmentHybridWebView:(NSString *)fbAppId;
+ (NSString *)AdjustBridge_js;

@end
2 changes: 1 addition & 1 deletion AdjustBridge/AdjustBridgeRegister.m
Expand Up @@ -75,7 +75,7 @@ + (NSString *)augmented_js {
}

+ (NSString *)adjust_js {
static NSString * preprocessorJSCode = @__adj_js_func__(;(function() {
static NSString *preprocessorJSCode = @__adj_js_func__(;(function() {
if (window.Adjust) {
return;
}
Expand Down
Expand Up @@ -12,21 +12,20 @@

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 1. Create the UIWebView example
UIWebViewController* UIWebViewExampleController = [[UIWebViewController alloc] init];
UIWebViewExampleController.tabBarItem.title = @"UIWebView";
UIWebViewController *uiWebViewExampleController = [[UIWebViewController alloc] init];
uiWebViewExampleController.tabBarItem.title = @"UIWebView";

// 2. Create the tab footer and add the UIWebView example
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController addChildViewController:UIWebViewExampleController];
[tabBarController addChildViewController:uiWebViewExampleController];

// 3. Create the WKWebView example for devices >= iOS 8
if ([WKWebView class]) {
WKWebViewController* WKWebViewExampleController = [[WKWebViewController alloc] init];
WKWebViewExampleController.tabBarItem.title = @"WKWebView";
[tabBarController addChildViewController:WKWebViewExampleController];
WKWebViewController *wkWebViewExampleController = [[WKWebViewController alloc] init];
wkWebViewExampleController.tabBarItem.title = @"WKWebView";
[tabBarController addChildViewController:wkWebViewExampleController];
}

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
Expand Down

0 comments on commit c4e8029

Please sign in to comment.