From ac586ac65ea9d9974bfa069b4685e081ccf081ce Mon Sep 17 00:00:00 2001 From: Michele Date: Tue, 29 May 2012 10:01:32 -0400 Subject: [PATCH] Added AppBlade PhoneGap plugin for iOS --- iOS/AppBlade/AppBlade.js | 40 +++++++++++++++++++++++++ iOS/AppBlade/AppBladePlugin.h | 19 ++++++++++++ iOS/AppBlade/AppBladePlugin.m | 55 +++++++++++++++++++++++++++++++++++ iOS/AppBlade/README.md | 20 +++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 iOS/AppBlade/AppBlade.js create mode 100644 iOS/AppBlade/AppBladePlugin.h create mode 100644 iOS/AppBlade/AppBladePlugin.m create mode 100644 iOS/AppBlade/README.md diff --git a/iOS/AppBlade/AppBlade.js b/iOS/AppBlade/AppBlade.js new file mode 100644 index 0000000..15195a3 --- /dev/null +++ b/iOS/AppBlade/AppBlade.js @@ -0,0 +1,40 @@ +/** + * AppBlade.js + * + * Phonegap AppBlade Instance plugin + * Copyright (c) AppBlade 2012 + * + */ + +// -------------------------------------------------------- + +var AppBlade = function(){}; + +// -------------------------------------------------------- + +AppBlade.prototype.setupAppBlade = function(project, token, secret, timestamp) { + cordova.exec("AppBlade.setupAppBlade", [project, token, secret, timestamp]); +}; + +AppBlade.prototype.catchAndReportCrashes = function() { + cordova.exec("AppBlade.catchAndReportCrashes"); +}; + +AppBlade.prototype.checkAuthentication = function() { + cordova.exec("AppBlade.checkAuthentication"); +}; + +AppBlade.prototype.allowFeedbackReporting = function() { + cordova.exec("AppBlade.allowFeedbackReporting"); +}; + +// -------------------------------------------------------- + +cordova.addConstructor(function() { + if (!window.Cordova) { + window.Cordova = cordova; + }; + + if(!window.plugins) window.plugins = {}; + window.plugins.appBlade = new AppBlade(); +}); \ No newline at end of file diff --git a/iOS/AppBlade/AppBladePlugin.h b/iOS/AppBlade/AppBladePlugin.h new file mode 100644 index 0000000..b85f615 --- /dev/null +++ b/iOS/AppBlade/AppBladePlugin.h @@ -0,0 +1,19 @@ +// +// AppBladePlugin.h +// HelloWorld +// +// Created by Michele Titolo on 5/14/12. +// Copyright (c) 2012 AppBlade. All rights reserved. +// + +#import + +@interface AppBladePlugin : CDVPlugin + +- (void)setupAppBlade:(NSMutableArray*)args withDict:(NSMutableDictionary*)options; + +- (void)catchAndReportCrashes:(NSMutableArray*)args withDict:(NSMutableDictionary*)options; +- (void)allowFeedbackReporting:(NSMutableArray*)args withDict:(NSMutableDictionary*)options; +- (void)checkAuthentication:(NSMutableArray*)args withDict:(NSMutableDictionary*)options; + +@end diff --git a/iOS/AppBlade/AppBladePlugin.m b/iOS/AppBlade/AppBladePlugin.m new file mode 100644 index 0000000..c6fd490 --- /dev/null +++ b/iOS/AppBlade/AppBladePlugin.m @@ -0,0 +1,55 @@ +// +// AppBladePlugin.m +// HelloWorld +// +// Created by Michele Titolo on 5/14/12. +// Copyright (c) 2012 AppBlade. All rights reserved. +// + +#import "AppBladePlugin.h" +#import "AppBlade.h" + +enum { + ABProjectID = 0, + ABToken, + ABSecretKey, + ABTimestamp +}; + +@implementation AppBladePlugin + +- (void)setupAppBlade:(NSMutableArray*)args withDict:(NSMutableDictionary*)options +{ + NSArray* keys = [args objectAtIndex:0]; + NSLog(@"Setup with stuff: %@", keys); + NSString* project = [keys objectAtIndex:ABProjectID]; + NSString* token = [keys objectAtIndex:ABToken]; + NSString* secret = [keys objectAtIndex:ABSecretKey]; + NSString* timestamp = [keys objectAtIndex:ABTimestamp]; + + AppBlade *blade = [AppBlade sharedManager]; + blade.appBladeProjectID = project; + blade.appBladeProjectToken = token; + blade.appBladeProjectSecret = secret; + blade.appBladeProjectIssuedTimestamp = timestamp; +} + +- (void)catchAndReportCrashes:(NSMutableArray *)args withDict:(NSMutableDictionary *)options +{ + NSLog(@"Catch and Report Crashes"); + [[AppBlade sharedManager] catchAndReportCrashes]; +} + +- (void)checkAuthentication:(NSMutableArray *)args withDict:(NSMutableDictionary *)options +{ + NSLog(@"Check approval"); + [[AppBlade sharedManager] checkApproval]; +} + +- (void)allowFeedbackReporting:(NSMutableArray *)args withDict:(NSMutableDictionary *)options +{ + NSLog(@"Allow Feedback"); + [[AppBlade sharedManager] allowFeedbackReporting]; +} + +@end diff --git a/iOS/AppBlade/README.md b/iOS/AppBlade/README.md new file mode 100644 index 0000000..0535324 --- /dev/null +++ b/iOS/AppBlade/README.md @@ -0,0 +1,20 @@ +AppBladeSDK PhoneGap Plugin +=================== + +Plugin for PhoneGap that uses the AppBlade SDK. + + +##Installation - iOS + +1. Copy `AppBlade.js` from into your `www` directory. +2. Copy `AppBladePlugin.[hm]` into your Plugins folder. +3. Follow directions for [adding plugins to your iOS project](http://wiki.phonegap.com/w/page/43708792/How%20to%20Install%20a%20PhoneGap%20Plugin%20for%20iOS). +3. Follow directions for [adding the AppBlade SDK to your project](http://github.com/AppBlade/SDK), but do not edit the `AppDelegate`. +4. Add `-all_load` to the `other linker flags` build setting for your target. +5. In your `index.html`, register for the `"deviceready"` eventListener, and call the setup method with your SDK keys in this order: project, token, secret, issued timestamp. + +See the Example project included for examples using the other functions of the SDK. + +##Resources: +###[AppBlade.com](https://appblade.com/) +###[License and Terms](https://appblade.com/terms_of_use) \ No newline at end of file