Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location targetting functions added (but still a work in progress) #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Classes/TiAdMobView.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@
@property (nonatomic, retain) NSTimer *refreshTimer;
@property (nonatomic, retain) AdMobView* admob;

@property (nonatomic, assign) double latitude;
@property (nonatomic, assign) double longitude;
@property (nonatomic, retain) NSDate* locationTime;

@end
33 changes: 32 additions & 1 deletion Classes/TiAdMobView.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@implementation TiAdMobView
@synthesize publisher, test, refresh, adBackgroundColor, primaryTextColor, secondaryTextColor;
@synthesize refreshTimer, admob;
@synthesize refreshTimer, admob, latitude, longitude, locationTime;

#pragma mark Cleanup

Expand All @@ -28,6 +28,8 @@ -(void)dealloc
[refreshTimer invalidate];
self.refreshTimer = nil;
self.admob = nil;
self.locationTime = nil;

[super dealloc];
}

Expand All @@ -45,6 +47,9 @@ -(void)initializeState
self.test = NO;
self.publisher = @"";
self.refresh = AD_REFRESH_PERIOD;
self.latitude = 0;
self.longitude = 0;
self.locationTime = nil;
}

-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
Expand Down Expand Up @@ -118,6 +123,17 @@ - (UIColor*)colorValue:(id)color_
return color;
}

- (double)locationLatitude {
return self.latitude;
}
- (double)locationLongitude {
return self.longitude;
}
- (NSDate *)locationTimestamp {
return self.locationTime;
}


#pragma Properties

-(void)setHeight_:(id)height_
Expand Down Expand Up @@ -160,6 +176,21 @@ -(void)setSecondaryTextColor_:(id)color
self.secondaryTextColor = [self colorValue:color];
}

-(void)setLatitude_:(id)latitude_
{
self.latitude = [TiUtils doubleValue:latitude_];
}

-(void)setLongitude_:(id)longitude_
{
self.longitude = [TiUtils doubleValue:longitude_];
}

-(void)setLocationTime_:(id)locationTime_
{
self.locationTime = [NSDate dateWithTimeIntervalSince1970:[TiUtils floatValue:locationTime_]/1000.0];
}

#pragma Public APIs

@end
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ HOW TO USE IT
adBackgroundColor: "#ffffff",
primaryTextColor: "#000000",
secondaryTextColor: "#000000",
refresh: 30.0
refresh: 30.0,
latitude: 51.0,
longitude: -0.180,
locationTime: new Date()
});
admob.addEventListener('error', function(error) {
alert(error.message);
Expand All @@ -38,7 +41,7 @@ INSTALL TiAdMob4iPhone
1. Open `Terminal`
2. Run below command

`python build.py && unzip jp.masuidrive.ti.admob-0.1.zip -d /Library/Application\ Support/Titanium/`
`python build.py && unzip jp.masuidrive.ti.admob-iphone-0.1.zip -d /Library/Application\ Support/Titanium/`


REGISTER TO YOUR PROJECT
Expand Down