Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed unused code, added more device property getters, updated docs

  • Loading branch information...
commit 9dbde374f2d1b0938e88513f1e6274bab307c56c 1 parent aaa38fc
Christian Sullivan authored
1  Classes/CountLyModule.h
View
@@ -10,5 +10,4 @@
@interface CountLyModule : TiModule
{
}
-
@end
153 Classes/CountLyModule.m
View
@@ -10,62 +10,10 @@
#import "TiUtils.h"
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
-
+#include <UIKit/UIKit.h>
#include <sys/types.h>
#include <sys/sysctl.h>
-/// Tool to decoded urld encoded string that Count.ly uses to send metrics
-/// Utilities for encoding and decoding URL arguments.
-/// This code is from the project google-toolbox-for-mac
-@interface NSString (GTMNSStringURLArgumentsAdditions)
-
-/// Returns a string that is escaped properly to be a URL argument.
-//
-/// This differs from stringByAddingPercentEscapesUsingEncoding: in that it
-/// will escape all the reserved characters (per RFC 3986
-/// <http://www.ietf.org/rfc/rfc3986.txt>) which
-/// stringByAddingPercentEscapesUsingEncoding would leave.
-///
-/// This will also escape '%', so this should not be used on a string that has
-/// already been escaped unless double-escaping is the desired result.
-- (NSString*)gtm_stringByEscapingForURLArgument;
-
-/// Returns the unescaped version of a URL argument
-//
-/// This has the same behavior as stringByReplacingPercentEscapesUsingEncoding:,
-/// except that it will also convert '+' to space.
-- (NSString*)gtm_stringByUnescapingFromURLArgument;
-
-@end
-
-#define GTMNSMakeCollectable(cf) ((id)(cf))
-#define GTMCFAutorelease(cf) ([GTMNSMakeCollectable(cf) autorelease])
-
-@implementation NSString (GTMNSStringURLArgumentsAdditions)
-
-- (NSString*)gtm_stringByEscapingForURLArgument {
- // Encode all the reserved characters, per RFC 3986
- // (<http://www.ietf.org/rfc/rfc3986.txt>)
- CFStringRef escaped =
- CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
- (CFStringRef)self,
- NULL,
- (CFStringRef)@"!*'();:@&=+$,/?%#[]",
- kCFStringEncodingUTF8);
- return GTMCFAutorelease(escaped);
-}
-
-- (NSString*)gtm_stringByUnescapingFromURLArgument {
- NSMutableString *resultString = [NSMutableString stringWithString:self];
- [resultString replaceOccurrencesOfString:@"+"
- withString:@" "
- options:NSLiteralSearch
- range:NSMakeRange(0, [resultString length])];
- return [resultString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-}
-
-@end
-
@implementation CountLyModule
#pragma mark Internal
@@ -86,8 +34,6 @@ -(NSString*)moduleId
-(void)startup
{
- // this method is called when the module is first loaded
- // you *must* call the superclass
[super startup];
NSLog(@"[INFO] %@ loaded",self);
}
@@ -119,27 +65,6 @@ -(void)didReceiveMemoryWarning:(NSNotification*)notification
[super didReceiveMemoryWarning:notification];
}
-#pragma mark Listener Notifications
-
--(void)_listenerAdded:(NSString *)type count:(int)count
-{
- if (count == 1 && [type isEqualToString:@"my_event"])
- {
- // the first (of potentially many) listener is being added
- // for event named 'my_event'
- }
-}
-
--(void)_listenerRemoved:(NSString *)type count:(int)count
-{
- if (count == 0 && [type isEqualToString:@"my_event"])
- {
- // the last listener called for event named 'my_event' has
- // been removed, we can optionally clean up any resources
- // since no body is listening at this point for that event
- }
-}
-
#pragma Public APIs
-(void)start:(id)args
@@ -202,18 +127,81 @@ - (id)device
return platform;
}
+- (id)deviceName
+{
+ return [[UIDevice currentDevice] name];
+}
+
+- (id)platform
+{
+ return [[UIDevice currentDevice] model];
+}
+
+- (id)multitaskingSupported
+{
+ return NUMBOOL([[UIDevice currentDevice] isMultitaskingSupported]);
+}
+
+- (id)orientation
+{
+ //Obtaining the current device orientation
+ UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
+
+ NSString* value = @"portrait";
+
+ switch(orientation){
+ // Device oriented vertically, home button on the bottom
+ case UIDeviceOrientationPortrait:
+ value = @"PORTRAIT";
+ break;
+ // Device oriented vertically, home button on the bottom
+ case UIDeviceOrientationPortraitUpsideDown:
+ value = @"PORTRAIT_UPSIDE_DOWN";
+ break;
+ // Device oriented vertically, home button on the top
+ case UIDeviceOrientationLandscapeLeft:
+ value = @"LANDSCAPE_LEFT";
+ break;
+ // Device oriented horizontally, home button on the right
+ case UIDeviceOrientationLandscapeRight:
+ value = @"LANDSCAPE_RIGHT";
+ break;
+ // Device oriented flat, face up
+ case UIDeviceOrientationFaceUp:
+ value = @"FACE_UP";
+ break;
+ // Device oriented flat, face down
+ case UIDeviceOrientationFaceDown:
+ value = @"FACE_DOWN";
+ break;
+ default:
+ value = @"UNKNOWN";
+ break;
+ }
+
+ return value;
+}
+
- (id)osVersion
{
return [[UIDevice currentDevice] systemVersion];
}
+- (id)systemName
+{
+ return [[UIDevice currentDevice] systemName];
+}
+
- (id)carrier
{
if (NSClassFromString(@"CTTelephonyNetworkInfo"))
{
CTTelephonyNetworkInfo *netinfo = [[[CTTelephonyNetworkInfo alloc] init] autorelease];
CTCarrier *carrier = [netinfo subscriberCellularProvider];
- return [carrier carrierName];
+ if ([carrier carrierName]) {
+ return [carrier carrierName];
+ }
+ return @"Simulator";
}
return @"Unknown";
@@ -224,9 +212,8 @@ - (id)resolution
CGRect bounds = [[UIScreen mainScreen] bounds];
CGFloat scale = [[UIScreen mainScreen] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.f;
CGSize res = CGSizeMake(bounds.size.width * scale, bounds.size.height * scale);
- NSString *result = [NSString stringWithFormat:@"%gx%g", res.width, res.height];
-
- return result;
+ return [TiUtils sizeToDictionary:res];
+
}
- (id)locale
@@ -239,5 +226,9 @@ - (id)appVersion
return [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleVersionKey];
}
+- (id)proximityState
+{
+ return NUMBOOL([[UIDevice currentDevice] proximityState]);
+}
-@end
+@end
21 README.md
View
@@ -16,14 +16,14 @@ Clone git repo and move to Titanium Modules Folder
```
$ git clone https://github.com/euforic/Ti-Count.ly.git
$ cd Ti-Count.ly
-$ cp count.ly-iphone-0.2.0.zip /Library/Application Support/Titanium/
+$ cp count.ly-iphone-0.2.1.zip /Library/Application Support/Titanium/
```
Register your module with your application by editing `tiapp.xml` and adding your module.
```
<modules>
- <module version="0.2.0">count.ly</module>
+ <module version="0.2.1">count.ly</module>
</modules>
```
@@ -89,12 +89,17 @@ countly.event({
### Metrics Data
```
-Ti.API.info(countly.device);
-Ti.API.info(countly.osVersion);
-Ti.API.info(countly.carrier);
-Ti.API.info(countly.resolution);
-Ti.API.info(countly.locale);
-Ti.API.info(countly.appVersion);
+console.log('device',countly.device);
+console.log('deviceName',countly.deviceName);
+console.log('devicePlatform',countly.platform)
+console.log('multitaskingSupported',countly.multitaskingSupported);
+console.log('orientation', countly.orientation);
+console.log('osVersion', countly.osVersion);
+console.log('carrier', countly.carrier);
+console.log('resolution', countly.resolution);
+console.log('locale',countly.locale);
+console.log('appVersion',countly.appVersion);
+console.log('osVersion',countly.osVersion);
```
## License
BIN  count.ly.xcodeproj/project.xcworkspace/xcuserdata/euforic.xcuserdatad/UserInterfaceState.xcuserstate
View
Binary file not shown
21 documentation/index.md
View
@@ -16,14 +16,14 @@ Clone git repo and move to Titanium Modules Folder
```
$ git clone https://github.com/euforic/Ti-Count.ly.git
$ cd Ti-Count.ly
-$ cp count.ly-iphone-0.2.0.zip /Library/Application Support/Titanium/
+$ cp count.ly-iphone-0.2.1.zip /Library/Application Support/Titanium/
```
Register your module with your application by editing `tiapp.xml` and adding your module.
```
<modules>
- <module version="0.2.0">count.ly</module>
+ <module version="0.2.1">count.ly</module>
</modules>
```
@@ -89,12 +89,17 @@ countly.event({
### Metrics Data
```
-Ti.API.info(countly.device);
-Ti.API.info(countly.osVersion);
-Ti.API.info(countly.carrier);
-Ti.API.info(countly.resolution);
-Ti.API.info(countly.locale);
-Ti.API.info(countly.appVersion);
+console.log('device',countly.device);
+console.log('deviceName',countly.deviceName);
+console.log('devicePlatform',countly.platform)
+console.log('multitaskingSupported',countly.multitaskingSupported);
+console.log('orientation', countly.orientation);
+console.log('osVersion', countly.osVersion);
+console.log('carrier', countly.carrier);
+console.log('resolution', countly.resolution);
+console.log('locale',countly.locale);
+console.log('appVersion',countly.appVersion);
+console.log('osVersion',countly.osVersion);
```
## License
17 example/app.js
View
@@ -15,12 +15,17 @@ win.open();
// TODO: write your module tests here
var countly = require('count.ly');
-console.log(countly.carrier);
-console.log(countly.osVersion);
-console.log(countly.appVersion);
-console.log(countly.resolution);
-console.log(countly.locale);
-console.log(countly.device);
+console.log('device',countly.device);
+console.log('deviceName',countly.deviceName);
+console.log('devicePlatform',countly.platform)
+console.log('multitaskingSupported',countly.multitaskingSupported);
+console.log('orientation', countly.orientation);
+console.log('osVersion', countly.osVersion);
+console.log('carrier', countly.carrier);
+console.log('resolution', countly.resolution);
+console.log('locale',countly.locale);
+console.log('appVersion',countly.appVersion);
+console.log('osVersion',countly.osVersion);
countly.start('APP_KEY','http://API_HOST.com');
4 manifest
View
@@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
-version: 0.2.0
+version: 0.2.1
apiversion: 2
description: Count.ly SDK Module
author: Christian Sullivan <cs@euforic.co>
@@ -15,4 +15,4 @@ name: count.ly
moduleid: count.ly
guid: ad1ce2b6-9511-403b-b5de-50c40542c433
platform: iphone
-minsdk: 2.1.1.GA
+minsdk: 2.1.1
Please sign in to comment.
Something went wrong with that request. Please try again.