Skip to content

Commit

Permalink
initial swizzling to bypass Estimote Cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepmistry committed Jul 29, 2015
1 parent 547d6a9 commit fe58343
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion Examples/beacons/Examples/ESTAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,61 @@
#import "ESTViewController.h"
#import <EstimoteSDK/EstimoteSDK.h>

#import <objc/runtime.h>

@interface ESTBeaconCloud

typedef void (^GetBeaconWithUIDBlockType)(ESTBeaconVO* beacon, NSError* error);
typedef void (^SaveConfigWithUIDBlockType)(ESTBeaconVO* beacon, NSError* error);

- (void)getBeaconWithUID:(id)arg1 completion:(GetBeaconWithUIDBlockType)arg2;
- (void)saveConfigWithBeacon:(id)arg1 completion:(SaveConfigWithUIDBlockType)arg2;

@end

@interface ESTBeaconCloud (Swizzled)

- (void)getBeaconWithUID:(id)arg1 completionSwizzled:(GetBeaconWithUIDBlockType)arg2;
- (void)saveConfigWithBeacon:(id)arg1 completionSwizzled:(SaveConfigWithUIDBlockType)arg2;

@end


@implementation ESTBeaconCloud (Swizzled)

+ (void)load
{
Method original, swizzled;

original = class_getInstanceMethod(self, @selector(getBeaconWithUID:completion:));
swizzled = class_getInstanceMethod(self, @selector(getBeaconWithUID:completionSwizzled:));
method_exchangeImplementations(original, swizzled);

original = class_getInstanceMethod(self, @selector(saveConfigWithBeacon:completion:));
swizzled = class_getInstanceMethod(self, @selector(saveConfigWithBeacon:completionSwizzled:));
method_exchangeImplementations(original, swizzled);
}

- (void)getBeaconWithUID:(id)arg1 completionSwizzled:(GetBeaconWithUIDBlockType)arg2
{
[self getBeaconWithUID:arg1 completionSwizzled:^(ESTBeaconVO* beacon, NSError* error) {
beacon = [[ESTBeaconVO alloc] init];

beacon.macAddress = arg1;

arg2(beacon, nil);
}];
}

- (void)saveConfigWithBeacon:(id)arg1 completionSwizzled:(SaveConfigWithUIDBlockType)arg2 {
[self saveConfigWithBeacon:arg1 completionSwizzled:^(ESTBeaconVO* beacon, NSError* error) {
arg2(arg1, nil);
}];
}

@end


@implementation ESTAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Expand All @@ -20,7 +75,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// in Account Settings tab.

NSLog(@"ESTAppDelegate: APP ID and APP TOKEN are required to connect to your beacons and make Estimote API calls.");
[ESTCloudManager setupAppID:nil andAppToken:nil];
[ESTCloudManager setupAppID:@"" andAppToken:@""];

// Estimote Analytics allows you to log activity related to monitoring mechanism.
// At the current stage it is possible to log all enter/exit events when monitoring
Expand Down

0 comments on commit fe58343

Please sign in to comment.