This commit is contained in:
Paul Panserrieu 2015-07-10 14:16:51 +02:00
Родитель b7f92c8385
Коммит e9a0897dc3
7 изменённых файлов: 52 добавлений и 21 удалений

Просмотреть файл

@ -1,4 +1,4 @@
# cordova-plugin-hockeyapp [![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges)
# cordova-plugin-hockeyapp
This plugin exposes the HockeyApp SDK for ios and android
@ -9,7 +9,7 @@ Including:
## Installation
cordova plugin add https://github.com/peutetre/cordova-plugin-hockeyapp.git
cordova plugin add cordova-plugin-hockeyapp
## Supported Platforms
@ -18,7 +18,7 @@ Including:
## Methods
- hockeyapp.start(success:function, error:function, appid:string):void
- hockeyapp.start(success:function, error:function, hockeyapp_id:string):void
Initialize HockeyApp SDK
@ -26,9 +26,13 @@ Initialize HockeyApp SDK
Display tester feedback UI
- hockeyapp.versionCheck(sucess:function, error:function):void
- hockeyapp.checkForUpdate(sucess:function, error:function):void
Check for a new vesion and notify the user if a newer version is available
Check for a new vesion
- hockeyapp.forceCrash():void
Force crash app
## Android tips

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "cordova-plugin-hockeyapp",
"version": "1.0.0",
"version": "1.1.0",
"description": "Cordova HockeyApp Plugin",
"cordova": {
"id": "com.zengularity.cordova.hockeyapp",

Просмотреть файл

@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-hockeyapp"
version="1.0.0">
version="1.1.0">
<name>HockeyApp</name>
<description>Cordova HockeyApp Plugin</description>
<license>Apache 2.0</license>

Просмотреть файл

@ -6,6 +6,13 @@ import org.json.JSONArray;
import net.hockeyapp.android.FeedbackManager;
import net.hockeyapp.android.UpdateManager;
import net.hockeyapp.android.CrashManager;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.lang.RuntimeException;
import java.lang.Runnable;
import java.lang.Thread;
public class HockeyApp extends CordovaPlugin {
@ -17,10 +24,17 @@ public class HockeyApp extends CordovaPlugin {
if (action.equals("start")) {
token = args.optString(0);
FeedbackManager.register(cordova.getActivity(), token, null);
CrashManager.register(cordova.getActivity(), token);
initialized = true;
callbackContext.success();
return true;
} else if(action.equals("feedback")) {
}
else if(actions.equals("checkForUpdate")) {
UpdateManager.register(cordova.getActivity(), token);
callbackContext.success();
return true;
}
else if(action.equals("feedback")) {
if(initialized) {
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
@ -35,12 +49,17 @@ public class HockeyApp extends CordovaPlugin {
callbackContext.error("cordova hockeyapp plugin not initialized, call start() first");
return false;
}
} else if(action.equals("versionCheck")) {
if (initialized) {
UpdateManager.register(cordova.getActivity(), token);
} else if(action.equals("forceCrash")) {
if(initialized) {
new Thread(new Runnable() {
public void run() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
throw new RuntimeException("Test crash at " + df.format(c.getTime()));
}
}).start();
return true;
}
else {
} else {
callbackContext.error("cordova hockeyapp plugin not initialized, call start() first");
return false;
}

Просмотреть файл

@ -7,6 +7,7 @@
- (void)start:(CDVInvokedUrlCommand*)command;
- (void)feedback:(CDVInvokedUrlCommand*)command;
- (void)versionCheck:(CDVInvokedUrlCommand*)command;
- (void)checkForUpdate:(CDVInvokedUrlCommand*)command;
- (void)forceCrash:(CDVInvokedUrlCommand*)command;
@end

Просмотреть файл

@ -47,7 +47,7 @@
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void) versionCheck:(CDVInvokedUrlCommand*)command
- (void) checkForUpdate:(CDVInvokedUrlCommand*)command
{
CDVPluginResult* pluginResult = nil;
if(initialized == YES) {
@ -55,9 +55,13 @@
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
}
else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"hockeyapp cordova plugin is not started, call hockeyapp.start(successcb, errorcb, appid) first!"];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"hockeyapp cordova plugin is not started, call hockeyapp.start(successcb, errorcb, hockeyapp_id) first!"];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void)forceCrash:(CDVInvokedUrlCommand *)command {
[[BITHockeyManager sharedHockeyManager].crashManager generateTestCrash];
}
@end

Просмотреть файл

@ -1,14 +1,17 @@
var exec = require('cordova/exec');
var hockeyapp = {
start:function(success, failure, token) {
start: function(success, failure, token) {
exec(success, failure, "HockeyApp", "start", [ token ]);
},
versionCheck:function(success, failure) {
exec(success, failure, "HockeyApp", "versionCheck", []);
},
feedback:function(success, failure) {
feedback: function(success, failure) {
exec(success, failure, "HockeyApp", "feedback", []);
},
forceCrash: function(success, failure) {
exec(success, failure, "HockeyApp", "forceCrash", []);
},
checkForUpdate: function(success, failure) {
exec(function () {}, function () {}, "HockeyApp", "checkForUpdate", []);
}
};