diff --git a/README.md b/README.md index 36b6464..a76f3a3 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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. @@ -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 diff --git a/src/android/HockeyApp.java b/src/android/HockeyApp.java index 2df5b60..a19cc75 100644 --- a/src/android/HockeyApp.java +++ b/src/android/HockeyApp.java @@ -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; @@ -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); diff --git a/src/ios/HockeyApp.m b/src/ios/HockeyApp.m index 6c37f12..2564ef7 100644 --- a/src/ios/HockeyApp.m +++ b/src/ios/HockeyApp.m @@ -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]; @@ -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 diff --git a/www/hockeyapp.js b/www/hockeyapp.js index 99c680f..d6303d5 100644 --- a/www/hockeyapp.js +++ b/www/hockeyapp.js @@ -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 @@ -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]); @@ -53,6 +54,11 @@ var hockeyapp = { EMAIL_ONLY: 1, EMAIL_PASSWORD: 2, VALIDATE: 3 + }, + + checkForUpdateMode: { + CHECK_ON_STARTUP: 0, + CHECK_MANUALLY: 2 } };