Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #83 from bmourat/update-option
Browse files Browse the repository at this point in the history
Added option to control check for updates functionality
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Aug 11, 2017
2 parents c8a0d1d + 19e3e5a commit 04dc00a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Immediately crashes the app. This is used strictly for testing the HockeyApp cra
### hockeyapp.start

```javascript
hockeyapp.start(successCallback: function, errorCallback: function, appId: string, autoSend?: boolean, ignoreDefaultHandler?: boolean, createNewFeedbackThread?: boolean, loginMode?: hockeyapp.loginMode, appSecret?: string): void
hockeyapp.start(successCallback: function, errorCallback: function, appId: string, autoSend?: boolean, checkForUpdateMode?: hockeyapp.checkForUpdateMode, ignoreDefaultHandler?: boolean, createNewFeedbackThread?: boolean, loginMode?: hockeyapp.loginMode, appSecret?: string): void
```

Initializes the HockeyApp plugin, and configures it with the appropriate app ID and user settings (e.g. should crash reports be automatically submitted).
Expand All @@ -214,11 +214,17 @@ Initializes the HockeyApp plugin, and configures it with the appropriate app ID

4. **autoSend** - Specifies whether you would like crash reports to be automatically sent to the HockeyApp server when the end user restarts the app. Defaults to `false`.

5. **ignoreDefaultHandler** - Specifies whether you would like to display the standard dialog when the app is about to crash. This parameter is only relevant on Android, and therefore, you can set it to anything on iOS. Defaults to `false`.
5. **checkForUpdateMode** - Specifies mode for checking updates.The `hockeyapp.checkForUpdateMode` enum provides the following available options:

6. **createNewFeedbackThread** - Indicates if a new thread should be created for each new feedback message. Setting it to `true` will force a new thread whenever a new message is sent as opposed to the default resume thread behaviour.
- `CHECK_ON_STARTUP` - Checks for updates on startup.

- `CHECK_MANUALLY` - Lets user to decide when to check for updates with `checkForUpdate` call.

6. **ignoreDefaultHandler** - Specifies whether you would like to display the standard dialog when the app is about to crash. This parameter is only relevant on Android, and therefore, you can set it to anything on iOS. Defaults to `false`.

7. **createNewFeedbackThread** - Indicates if a new thread should be created for each new feedback message. Setting it to `true` will force a new thread whenever a new message is sent as opposed to the default resume thread behaviour.

7. **loginMode** - The mechanism to use in order to authenticate users. Defaults to `hockeyapp.loginMode.ANONYMOUS`. The `hockeyapp.loginMode` enum provides the following available options:
8. **loginMode** - The mechanism to use in order to authenticate users. Defaults to `hockeyapp.loginMode.ANONYMOUS`. The `hockeyapp.loginMode` enum provides the following available options:

- `ANONYMOUS` - The end user isn't authenticated at all.

Expand All @@ -230,7 +236,7 @@ Initializes the HockeyApp plugin, and configures it with the appropriate app ID

*NOTE: Only the `ANONYMOUS` login mode is supported on iOS, and therefore, you can only use the other modes within Android apps.*

8. **appSecret** - The app secret as provided by the HockeyApp portal. This parameter only needs to be set if you're setting the `loginMode` parameter to `EMAIL_ONLY`.
9. **appSecret** - The app secret as provided by the HockeyApp portal. This parameter only needs to be set if you're setting the `loginMode` parameter to `EMAIL_ONLY`.

### hockeyapp.trackEvent

Expand Down
7 changes: 6 additions & 1 deletion src/android/HockeyApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class HockeyApp extends CordovaPlugin {
public static final long XWALK_SCREENSHOT_WAIT_MS = 5000;
public static final String XWALK_SCREENSHOT_CAPTURE_MSG = "captureXWalkBitmap";
public static final String XWALK_SCREENSHOT_BITMAP_MSG = "onGotXWalkBitmap";
private static final int CHECK_UPDATE_ON_STARTUP = 0;

public static boolean initialized = false;
public static String appId;
Expand Down Expand Up @@ -103,10 +104,14 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
boolean autoSend = args.optBoolean(3);
boolean ignoreDefaultHandler = args.optBoolean(4, false);
boolean shouldCreateNewFeedbackThread = args.optBoolean(5, false);

FeedbackManager.register(cordova.getActivity(), appId, shouldCreateNewFeedbackThread ? new SingleThreadFeedbackManagerListener() : null);
this.crashListener = new ConfiguredCrashManagerListener(autoSend, ignoreDefaultHandler);

final int checkForUpdateMode = args.optInt(6, CHECK_UPDATE_ON_STARTUP);
if (checkForUpdateMode == CHECK_UPDATE_ON_STARTUP) {
UpdateManager.register(cordova.getActivity(), appId);
}

MetricsManager.register(cordova.getActivity(), cordova.getActivity().getApplication(), appId);
CrashManager.register(cordova.getActivity(), appId, this.crashListener);

Expand Down
3 changes: 3 additions & 0 deletions src/ios/HockeyApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ - (void) start:(CDVInvokedUrlCommand*)command
NSString* token = [arguments objectAtIndex:0];
NSString* autoSend = [arguments objectAtIndex:3];
NSString* createNewFeedbackThread = [arguments objectAtIndex:5];
NSString* checkForUpdateModeString = [arguments objectAtIndex:6];
NSInteger checkForUpdateMode = [checkForUpdateModeString intValue];
// no-op this for now. Appears to do nothing on ios side?
// NSString* ignoreDefaultHandler = [arguments objectAtIndex:4];

Expand All @@ -40,6 +42,7 @@ - (void) start:(CDVInvokedUrlCommand*)command

[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:token
delegate:self];
[[BITHockeyManager sharedHockeyManager] updateManager].updateSetting = checkForUpdateMode;
[[BITHockeyManager sharedHockeyManager] startManager];

// Set authentication mode prior to verifying the user
Expand Down
10 changes: 8 additions & 2 deletions www/hockeyapp.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var exec = require('cordova/exec');

var hockeyapp = {
start: function(success, failure, appId, autoSend, ignoreDefaultHandler, createNewFeedbackThread, loginMode, appSecret) {
start: function(success, failure, appId, autoSend, checkForUpdateMode, ignoreDefaultHandler, createNewFeedbackThread, loginMode, appSecret) {
autoSend = (autoSend === true || autoSend === "true");
ignoreDefaultHandler = (ignoreDefaultHandler === true || ignoreDefaultHandler === "true");
loginMode = loginMode || hockeyapp.loginMode.ANONYMOUS;
appSecret = appSecret || '';
checkForUpdateMode = checkForUpdateMode || hockeyapp.checkForUpdateMode.CHECK_ON_STARTUP;
createNewFeedbackThread = (createNewFeedbackThread === true || createNewFeedbackThread === "true");

// Requesting loginMode.EMAIL_ONLY without an appSecret is not permitted
Expand All @@ -16,7 +17,7 @@ var hockeyapp = {
return;
}

exec(success, failure, "HockeyApp", "start", [appId, loginMode, appSecret, autoSend, ignoreDefaultHandler, createNewFeedbackThread]);
exec(success, failure, "HockeyApp", "start", [appId, loginMode, appSecret, autoSend, ignoreDefaultHandler, createNewFeedbackThread, checkForUpdateMode]);
},
setUserEmail: function (success, failure, userEmail) {
exec(success, failure, "HockeyApp", "setUserEmail", [userEmail]);
Expand Down Expand Up @@ -53,6 +54,11 @@ var hockeyapp = {
EMAIL_ONLY: 1,
EMAIL_PASSWORD: 2,
VALIDATE: 3
},

checkForUpdateMode: {
CHECK_ON_STARTUP: 0,
CHECK_MANUALLY: 2
}
};

Expand Down

0 comments on commit 04dc00a

Please sign in to comment.