Removing setting of window.data and fixed some indentations
This commit is contained in:
Родитель
be73502c5d
Коммит
5f9dbbc951
14
plugin.xml
14
plugin.xml
|
@ -10,7 +10,7 @@
|
|||
<keywords>cordova,device</keywords>
|
||||
<url>http://docs.telerik.com/platform/appfeedback</url>
|
||||
<engines>
|
||||
<engine name="cordova-ios" version=" >=3" />
|
||||
<engine name="cordova-ios" version=">=3" />
|
||||
<engine name="cordova-android" version=">=4" />
|
||||
</engines>
|
||||
|
||||
|
@ -39,13 +39,13 @@
|
|||
<framework src="Foundation.framework" weak="true" />
|
||||
|
||||
<config-file target="*-Info.plist" parent="apiKey">
|
||||
<string>$API_KEY</string>
|
||||
<string>$API_KEY</string>
|
||||
</config-file>
|
||||
<config-file target="*-Info.plist" parent="apiUrl">
|
||||
<string>$API_URL</string>
|
||||
<string>$API_URL</string>
|
||||
</config-file>
|
||||
<config-file target="*-Info.plist" parent="enableShake">
|
||||
<string>$ENABLE_SHAKE</string>
|
||||
<string>$ENABLE_SHAKE</string>
|
||||
</config-file>
|
||||
</platform>
|
||||
|
||||
|
@ -69,9 +69,9 @@
|
|||
|
||||
<source-file src="src/android/res/values/feedback.xml" target-dir="res/values" />
|
||||
<config-file target="res/values/strings.xml" parent="/*">
|
||||
<string name="apiKey">$API_KEY</string>
|
||||
<string name="apiUrl">$API_URL</string>
|
||||
<string name="enableShake">$ENABLE_SHAKE</string>
|
||||
<string name="apiKey">$API_KEY</string>
|
||||
<string name="apiUrl">$API_URL</string>
|
||||
<string name="enableShake">$ENABLE_SHAKE</string>
|
||||
</config-file>
|
||||
|
||||
<config-file target="AndroidManifest.xml" parent="/*">
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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;
|
Загрузка…
Ссылка в новой задаче