diff --git a/plugin.xml b/plugin.xml index a7e05d6..3150c4f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -10,7 +10,7 @@ cordova,device http://docs.telerik.com/platform/appfeedback - + @@ -39,13 +39,13 @@ - $API_KEY + $API_KEY - $API_URL + $API_URL - $ENABLE_SHAKE + $ENABLE_SHAKE @@ -69,9 +69,9 @@ - $API_KEY - $API_URL - $ENABLE_SHAKE + $API_KEY + $API_URL + $ENABLE_SHAKE diff --git a/src/android/com/telerik/feedback/AppFeedback.java b/src/android/com/telerik/feedback/AppFeedback.java index 4d27b89..0c4e6d1 100644 --- a/src/android/com/telerik/feedback/AppFeedback.java +++ b/src/android/com/telerik/feedback/AppFeedback.java @@ -21,26 +21,25 @@ public class AppFeedback extends CordovaPlugin implements RadFeedback.OnSendFeed @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("GetVariables")) { - JSONObject data = new JSONObject(); - for (int i = 0; i < args.length(); i++) { - try { - String variableName = args.getString(i); - int appResId = cordova.getActivity().getResources().getIdentifier(variableName, "string", cordova.getActivity().getPackageName()); - String variableValue = cordova.getActivity().getString(appResId); - data.put(variableName, variableValue); - } catch(Exception ex) { + JSONObject data = new JSONObject(); + for (int i = 0; i < args.length(); i++) { + try { + String variableName = args.getString(i); + int appResId = cordova.getActivity().getResources().getIdentifier(variableName, "string", cordova.getActivity().getPackageName()); + String variableValue = cordova.getActivity().getString(appResId); + data.put(variableName, variableValue); + } catch(Exception ex) { + } } - } - callbackContext.success(data); - return true; + callbackContext.success(data); + return true; } if (action.equalsIgnoreCase("initialize")) { this.initialize(args); } else if (action.equalsIgnoreCase("showfeedback")) { this.showFeedback(); - } else { + } else { callbackContext.error("Method not found"); return false; } diff --git a/src/ios/TLRKFeedback.m b/src/ios/TLRKFeedback.m index 1f19db9..69207d8 100644 --- a/src/ios/TLRKFeedback.m +++ b/src/ios/TLRKFeedback.m @@ -33,23 +33,24 @@ -(void)GetVariables:(CDVInvokedUrlCommand*)command { - NSMutableDictionary *values = [NSMutableDictionary dictionary]; - int i; - for (i = 0; i < [command.arguments count]; i++) - { - @try + NSMutableDictionary *values = [NSMutableDictionary dictionary]; + int i; + for (i = 0; i < [command.arguments count]; i++) { - NSString *variableName = [command argumentAtIndex:i]; - NSString *variableValue = [[[NSBundle mainBundle] infoDictionary] objectForKey:variableName]; - [values setObject:variableValue forKey:variableName]; + @try + { + NSString *variableName = [command argumentAtIndex:i]; + NSString *variableValue = [[[NSBundle mainBundle] infoDictionary] objectForKey:variableName]; + [values setObject:variableValue forKey:variableName]; + } + @catch (NSException *exception) + { + } } - @catch (NSException *exception) - { - } - } - CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:values]; - NSString *callbackId = [command callbackId]; - [self success:result callbackId:callbackId]; + CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:values]; + NSString *callbackId = [command callbackId]; + [self success:result callbackId:callbackId]; } + @end \ No newline at end of file diff --git a/www/feedback.js b/www/feedback.js index 97dd01a..2427e5d 100644 --- a/www/feedback.js +++ b/www/feedback.js @@ -1,7 +1,7 @@ 'use strict'; var cordova = require('cordova'), - API_BASE_URL = 'https://platform.telerik.com/feedback/api/v1', + API_BASE_URL = 'https://platform.telerik.com/feedback/api/v1', Feedback = function () { this.initialize = function (apiKey, options) { var that = this; @@ -42,22 +42,20 @@ var cordova = require('cordova'), }; }, feedback = new Feedback(); - -window.addEventListener('deviceready', function () { - cordova.exec(function(data) { - if(data.apiKey !== "YourKeyHere"){ - var shouldEnableShake = data.enableShake === 'true' - var feedbackOptions = { - enableShake: shouldEnableShake, - apiUrl: data.apiUrl - }; - feedback.initialize(data.apiKey, feedbackOptions); - } - }, function(err) { - window.data = err; - console.log('Unable to read required plugin variables: ' + err); - }, 'AppFeedback', 'GetVariables', [ 'apiKey', 'apiUrl', 'enableShake' ]); +window.addEventListener('deviceready', function () { + cordova.exec(function(data) { + if (data.apiKey !== 'YourKeyHere') { + var shouldEnableShake = (data.enableShake || '').toLowerCase() === 'true'; + var feedbackOptions = { + enableShake: shouldEnableShake, + apiUrl: data.apiUrl + }; + feedback.initialize(data.apiKey, feedbackOptions); + } + }, function(err) { + console.log('Unable to read required plugin variables: ' + err); + }, 'AppFeedback', 'GetVariables', [ 'apiKey', 'apiUrl', 'enableShake' ]); }, true); module.exports = feedback; \ No newline at end of file