Skip to content

Commit

Permalink
feat(ios): implement SDK v6.2.0 public interface new methods
Browse files Browse the repository at this point in the history
Success method now accepts any type, not only boolean, to align with default data masking
  • Loading branch information
hiteshjain29 committed Jun 21, 2019
1 parent 7f8ad2d commit b2bdb68
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ios/FeedbackController.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Usabilla

protocol ResultDelegate: class {
func success(completed: Bool)
func success(completed: Any)
func error()
}

Expand Down
37 changes: 36 additions & 1 deletion src/ios/UsabillaCordova.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Usabilla
var appId: String?
var customVariables: [String: Any]?
var eventName: String?
var masks: [String]?
var maskChar: String?

// Extracts the variables sent from Usabilla.js
func extractCustomVariables(command: CDVInvokedUrlCommand) {
Expand All @@ -18,6 +20,10 @@ import Usabilla
self.appId = value as? String
} else if (key == "FORM_ID") {
self.formId = value as? String
} else if (key == "MASKS") {
self.masks = value as? [String]
} else if (key == "MASK_CHAR") {
self.maskChar = value as? String
} else {
if (value is String) {
arguments[key] = value as? String
Expand Down Expand Up @@ -98,8 +104,37 @@ import Usabilla
self.success(completed: true)
}
}

// Set Dismiss to close the campaign
@objc(dismiss:)
func dismiss(_ command: CDVInvokedUrlCommand) {
self.command = command;
let _ = Usabilla.dismiss()
self.success(completed: true)
}

// Default Data masking
@objc(getDefaultDataMasks:)
func getDefaultDataMasks(_ command: CDVInvokedUrlCommand) {
self.command = command;
let str = Usabilla.defaultDataMasks
self.success(completed: str)
}

// Set Data masking
@objc(setDataMasking:)
func setDataMasking(_ command: CDVInvokedUrlCommand) {
self.command = command;
self.extractCustomVariables(command: command);
if let maskCharacter = self.maskChar?.first, let mask = self.masks {
Usabilla.setDataMasking(masks: mask, maskCharacter: maskCharacter)
} else {
Usabilla.setDataMasking(masks: Usabilla.defaultDataMasks, maskCharacter: "X")
}
self.success(completed: true)
}

func success(completed: Bool) {
func success(completed: Any) {
let result = ["completed": completed] as [AnyHashable : Any]
let pluginResult = CDVPluginResult(
status: CDVCommandStatus_OK,
Expand Down
8 changes: 8 additions & 0 deletions www/Usabilla.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ Usabilla.prototype.dismiss = function(success, fail) {
"dismiss");
};

Usabilla.prototype.getDefaultDataMasks = function(success, fail) {
return cordova.exec(
success,
fail,
"UsabillaCordova",
"getDefaultDataMasks");
};

Usabilla.prototype.setDataMasking = function(success, fail, masks, maskCharacter) {
var vars = {};
vars['MASKS'] = masks;
Expand Down

0 comments on commit b2bdb68

Please sign in to comment.