diff --git a/plugin.xml b/plugin.xml index 6ff0b24..bdccc49 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,14 +2,16 @@ + version="2.0.0"> + Telerik AppFeedback This plugin allows the app to include Telerik AppFeedback functionality on device shake. Commercial cordova,device http://docs.telerik.com/platform/appfeedback - + + @@ -37,13 +39,13 @@ - $API_KEY + $API_KEY - $API_URL + $API_URL - $ENABLE_SHAKE + $ENABLE_SHAKE @@ -67,9 +69,9 @@ - $API_KEY - $API_URL - $ENABLE_SHAKE + $API_KEY + $API_URL + $ENABLE_SHAKE @@ -77,8 +79,7 @@ - + - \ No newline at end of file diff --git a/src/android/FeedbackLib/build-extras.gradle b/src/android/FeedbackLib/build-extras.gradle new file mode 100644 index 0000000..dc894da --- /dev/null +++ b/src/android/FeedbackLib/build-extras.gradle @@ -0,0 +1,3 @@ +dependencies { + compile 'com.android.support:appcompat-v7:22.2.1' +} \ No newline at end of file diff --git a/src/android/FeedbackLib/libs/Feedback.jar b/src/android/FeedbackLib/libs/Feedback.jar index 309f814..c319896 100644 Binary files a/src/android/FeedbackLib/libs/Feedback.jar and b/src/android/FeedbackLib/libs/Feedback.jar differ diff --git a/src/android/com/telerik/feedback/AppFeedback.java b/src/android/com/telerik/feedback/AppFeedback.java index 4d27b89..d483cf0 100644 --- a/src/android/com/telerik/feedback/AppFeedback.java +++ b/src/android/com/telerik/feedback/AppFeedback.java @@ -21,26 +21,24 @@ 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; - } - if (action.equalsIgnoreCase("initialize")) { + callbackContext.success(data); + return true; + } else 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)showFeedback: (CDVInvokedUrlCommand *)command -(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..1eb81b7 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; @@ -11,7 +11,7 @@ var cordova = require('cordova'), } if (options) { - options.enableShake = options.enableShake === 'undefined' ? true : options.enableShake; + options.enableShake = typeof options.enableShake === 'undefined' ? true : options.enableShake; } else { options = { enableShake: true @@ -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